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

SH_WORD_SPLIT, $* and null IFS



Hello Everyone,

I encountered some strange behavior with the SH_WORD_SPLIT option and i was
wondering if someone could give me some insight on the matter.

When SH_WORD_SPLIT is set, Zsh will use the IFS to split words during
variable expansion...

But there is apparently some other side effects as well... One of them is
the handling of the special parameter $* and it's double quoted form "$*".

When SH_WORD_SPLIT is NOT set (the default):
- "$*" expand to a single field, with each parameter separated by the IFS.
-  $*   will not care about the IFS, and expand all parameters as usual
(individually).

When SH_WORD_SPLIT is set:
- "$*" expand to a single field, with each parameter separated by the IFS
(same as before).
-  $    will not care about the IFS... EXCEPT if the IFS is null (set to no
value)... then it will also expands to a single field without delimiters

I really don't understand this last behavior...

SH_WORD_SPLIT is a compatibility feature which is automatically triggered
when zsh is invoked as sh or ksh. This behavior is effectively reproducible
using Dash (so this is probably not a bug), but not ksh, nor Bash (even if
invoked as sh, and using the --posix option).

So... it is some kind of POSIX specificity? Or just a hack? Do you know what
was really intended here?

Thanks

Paul


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