Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Read-only variables in emulation mode
- X-seq: zsh-workers 32135
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Oystein Walle <oystwa@xxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Read-only variables in emulation mode
- Date: Mon, 16 Dec 2013 11:40:13 -0800
- In-reply-to: <CAFaJEqs=P7yB-VGk=gJB2jzRf7zNiDkCuWWRADyY_xb52hGb_w@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAFaJEqs=P7yB-VGk=gJB2jzRf7zNiDkCuWWRADyY_xb52hGb_w@mail.gmail.com>
On Dec 16, 8:10pm, Oystein Walle wrote:
} Subject: Read-only variables in emulation mode
}
} I assume status and _ are meant to be writable in POSIX shells.
Hmm. According to the doc, "status" should be writable but "_" not.
status <S> <Z>
_ <S>
(The <S> means "special", the <Z> means "but only in native zsh mode".)
} A common idiom in (ba)sh scripting is to use _ as a throwaway in a
} while-read loop:
}
} while read -r col1 _ col2; do
} echo "col1 = $col1 and col2 = $col2"
} done < three-columns.txt
Well, that's one I'd never seen before. Certainly that's about the only
place it's "safe" to use "_" because it's always immediately going to be
clobbered.
} In the mean time, is there any way around it?
Only by using a function scope and declaring "local -h _ status" to hide
the special variables.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author