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

Re: shwordsplit and ksharrays will change rcexpandparam's behavior on empty array



On Sep 13,  9:05pm, Han Pingtian wrote:
}
} % zsh -c 'xx=(); print foo${^xx}bar'
} <empty>
} % zsh -c 'setopt shwordsplit;xx=(); print foo${^xx}bar'
} foobar

Hmm ... "shwordsplit" is of course code for doing several expansion-
related things in a Bourne-shell-like way, mostly but not exclusively
splitting on spaces ... it's consistently applied:

% xx=(); print foo${=^xx}bar
foobar
% 

You can see that this has to do with the difference between $* and $@ if
you make it explicit:

% xx=(); print foo${=^xx[@]}bar

% xx=(); print foo${=^xx[*]}bar
foobar
% 

} % zsh -c 'setopt ksharrays;xx=(); print foo${^xx}bar'
} foobar

This one, however, is definitely correct.  With ksharrays, ${xx} means
the same as ${xx[0]}, not ${xx[*]}.



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