From: Martijn Dekker <martijn@inlv.org>
To: zsh-workers@zsh.org
Subject: Field splitting: extra empty field with final non-whitespace IFS character
Date: Mon, 22 Jun 2015 05:06:21 +0200 [thread overview]
Message-ID: <55877BAD.7080700@inlv.org> (raw)
% 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
next reply other threads:[~2015-06-22 3:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 3:06 Martijn Dekker [this message]
2015-06-24 6:43 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55877BAD.7080700@inlv.org \
--to=martijn@inlv.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).