Invalid test for `shwordsplit` being set in zsh #269

Closed
ZyX-I opened this Issue Oct 12, 2012 · 1 comment

Comments

Projects
None yet
1 participant

ZyX-I commented Oct 12, 2012

According to the zsh docs, setopt will print shwordsplit option only if its value differs from default one in current emulation mode. If /bin/sh happens to be a symlink to zsh then shwordsplit option is set by default and thus test fails. Test that shows the problem:

ln -s /bin/zsh ./sh
./sh -c 'setopt ; A="a  b  c" ; echo $A'

will output

nohashdirs
a b c

, while

zsh -c 'setopt ; A="a  b  c" ; echo $A'

outputs

nohashdirs
a  b  c

(note amount of spaces between letters, it clearly indicates whether zsh is performing word splitting on a variable).

A valid way to test option (not) being set is checking whether word splitting is actually being performed:

if [[ "$(unset IFS; A='a  b'; echo -n $A)" != "a b" ]]; then

.

Here is a link to a stackoverflow question where the problem appeared.

ZyX-I commented Oct 12, 2012

Oops, that should be there: nvie/shFlags#1.

@ZyX-I ZyX-I closed this Oct 12, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment