Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: RC_EXPAND_PARAM final patch



Andrej Borsenkow wrote:
> % a=(a "b ")
> % x=(x "y z")
[...]
> % setopt shwordsplit
> % args ${^a}1
> "a1" "b1" "1"
> % args ${^x}1
> "x1" "y1" "z1"     ????
>
> Shouldn't it be  "x1" "y" "z1"  ?

Why? ${^x} in itself expands to 3 words, x y z, and that's combined with
`1'.  With sh_word_split, a word with spaces acts like an array.

The first example is a bit more hard to understand.  Here ${^a} expands to
3 words too, but the last word is a null word, which is removeded from the
argument list, unless it is contacenated with something real.  That's why
${^a}1 expands to a1 b1 1, just immagine an invisible zero-length word
before the last 1.

Zoltan



Messages sorted by: Reverse Date, Date, Thread, Author