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

Field splitting: extra empty field with final non-whitespace IFS character



% emulate sh
% IFS=':'
% x='a:b::'
% set -- $x
% echo $#
4

zsh counts 4 fields instead of 3, like most other shells do. In other
words, zsh does not treat the non-whitespace IFS character as a field
terminator.

POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05
"The shell shall treat each character of the IFS as a delimiter and use
the delimiters as field TERMINATORS to split the results of parameter
expansion and command substitution into fields." (emphasis mine)

bash, ash, dash, ksh93 and mksh act according to POSIX.

pdksh (which is obsolete) and yash act like zsh.

I think this should be changed to match the behaviour specified by POSIX
in sh and ksh emulation modes.

Thanks,

- Martijn



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