Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Field splitting: extra empty field with final non-whitespace IFS character
- X-seq: zsh-workers 35560
- From: Martijn Dekker <martijn@xxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Field splitting: extra empty field with final non-whitespace IFS character
- Date: Mon, 22 Jun 2015 05:06:21 +0200
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
% 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