Zsh Mailing List Archive
Messages sorted by:
Re: Reading line by line
- X-seq: zsh-users 11390
- From: Micah Cowan <micah@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Reading line by line
- Date: Wed, 11 Apr 2007 12:40:09 -0700
- In-reply-to: <20070411191953.GF4996@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <242911.74922.qm@xxxxxxxxxxxxxxxxxxxxxxxxx> <461D2541.1080104@xxxxxxxxxx> <20070411183602.GD4996@xxxxxxxxxxxxxxx> <461D2E79.6070907@xxxxxxxxxx> <20070411191953.GF4996@xxxxxxxxxxxxxxx>
Stephane Chazelas wrote:
On Wed, Apr 11, 2007 at 11:52:41AM -0700, Micah Cowan wrote:
$ echo 'a b' | read -r
zsh will preserve all whitespace between a and b, whereas other shells
will condense it to a single space. POSIX states that, after splitting
the fields, if there is only one variable name left in the args, all
remaining fields will be assigned to that variable, with "their
intervening separation", which IMO is difficult to interpret as anything
other than the original separation that had been encountered.
No, you must have been confused by word splitting occuring upon
unquoted variable expansions.
Perhaps. I could've sworn I'd quoted it... but now that I think about
it, I probably used OP's example, which has it unquoted.
echo 'a b' | read a
outputs "a b"
That's what POSIX requires and that's how zsh behaves when
in POSIX emulation.
Right; I was talking about bash, dash and ksh behavior not being
compliant, not zsh. But, if I did indeed leave it unquoted, that would
explain the difference, since zsh, by default, does not field-split
Note that word splitting is not the only thing performed by
POSIX shells upon variable expansion, there's also filename
generation. That's why one should *NEVER* leave variables
unquoted in POSIX scripts.
Agreed, absolutely. Well... s/*NEVER*/only when you know that word
expansion is actually what you really want/
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
Messages sorted by: