Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: bug in ${(z)...} with newlines
- X-seq: zsh-workers 28014
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: PATCH: bug in ${(z)...} with newlines
- Date: Wed, 9 Jun 2010 07:34:47 -0700
- In-reply-to: <15865.1276088859@xxxxxxx>
- 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: <15865.1276088859@xxxxxxx>
On Wed, Jun 9, 2010 at 6:07 AM, Peter Stephenson <pws@xxxxxxx> wrote:
> This must be a bug, mustn't it?
>
> % foo=$'one\ntwo'
> % print ${(z)foo}
> one ; two
I'm pretty sure that's intentional, so that when the newline is
removed by splitting, the join is still a semantically equivalent
shell expression. Otherwise you can't do stuff like this:
foo=(${(q)${(z)foo}})
bar=time
for word in $foo
do if [[ $word == '\;' ]]
then bar+=($word time)
else bar+=($word)
fi
done
eval $bar
In fact if newline is not replaced with semicolon by (z), I think it
becomes impossible to find command words by searching through the
resulting array.
> As far as splitting arguments goes, the newline is just whitespace.
Yes, but (z) is really for parsing, not merely splitting.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author