zsh-workers
 help / color / mirror / code / Atom feed
* Field splitting: extra empty field with final non-whitespace IFS character
@ 2015-06-22  3:06 Martijn Dekker
  2015-06-24  6:43 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Martijn Dekker @ 2015-06-22  3:06 UTC (permalink / raw)
  To: zsh-workers

% 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-24  6:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-22  3:06 Field splitting: extra empty field with final non-whitespace IFS character Martijn Dekker
2015-06-24  6:43 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).