* shwordsplit and ksharrays will change rcexpandparam's behavior on empty array
@ 2012-09-13 13:05 Han Pingtian
2012-09-13 15:05 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Han Pingtian @ 2012-09-13 13:05 UTC (permalink / raw)
To: zsh-users
Hello,
I noticed that 'shwordsplit' will change the behavior of 'rcexpandparam'
on empty array:
% zsh -c 'xx=(); print foo${^xx}bar'
<empty>
% zsh -c 'setopt shwordsplit;xx=(); print foo${^xx}bar'
foobar
Not sure if this is a bug.
And looks like 'ksharrays' can do this, too:
% zsh -c 'setopt ksharrays;xx=(); print foo${^xx}bar'
foobar
Maybe ksharrays lets the $xx evluated as a scalar, a null string, so
foo${^xx}bar is return as foobar?
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: shwordsplit and ksharrays will change rcexpandparam's behavior on empty array
2012-09-13 13:05 shwordsplit and ksharrays will change rcexpandparam's behavior on empty array Han Pingtian
@ 2012-09-13 15:05 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2012-09-13 15:05 UTC (permalink / raw)
To: zsh-users
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[*]}.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-13 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-13 13:05 shwordsplit and ksharrays will change rcexpandparam's behavior on empty array Han Pingtian
2012-09-13 15:05 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).