GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
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'
a b c
zsh -c 'setopt ; A="a b c" ; echo $A'
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.
Oops, that should be there: nvie/shFlags#1.