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

Inconsistency with SHWORDSPLIT and leading spaces



Hi,

I noticed the following different behavior trying to use zsh as /bin/sh:

juno ~% dash -c 'x=foo; echo x${x:+ $x}' 
x foo
juno ~% bash -c 'x=foo; echo x${x:+ $x}' 
x foo
juno ~% mksh -c 'x=foo; echo x${x:+ $x}' 
x foo
juno ~% ksh -c 'x=foo; echo x${x:+ $x}' 
x foo
juno ~% zsh -c 'x=foo; echo x${x:+ $x}' 
x foo
juno ~% zsh -c 'emulate -L sh; x=foo; echo x${x:+ $x}'           
xfoo
juno ~% zsh -c 'emulate -L ksh; x=foo; echo x${x:+ $x}' 
xfoo
juno ~% zsh -c 'setopt shwordsplit; x=foo; echo x${x:+ $x}' 
xfoo

zsh 5.1.1 (x86_64-unknown-linux-gnu)
zsh-5.1.1-0-g68405f3

It's not clear to me whether this is *actually* POSIX-nonconformant, but
it's at least surprising compared to the other POSIX-compatible shells.

Thanks,
-- 
Christian Neukirchen  <chneukirchen@xxxxxxxxx>  http://chneukirchen.org



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