From: Felipe Contreras <felipe.contreras@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Discrepancy in IFS handling (zsh is POSIX compliant)
Date: Thu, 30 Mar 2023 05:11:46 -0600 [thread overview]
Message-ID: <CAMP44s31HWYdR+Qn7w7yxzsboheEf_6xFv4yv6qGS8NBT_pqhA@mail.gmail.com> (raw)
Hi,
I was going to report a bug about a discrepancy in the handling of
IFS, until I read what the POSIX standard says about it [1].
The example is this:
IFS=,
str='foo,bar,,roo,'
printf '"%s"\n' $str
In bash there's four fields, the last comma is ignored, in zsh there's
five fields. In my system dash and ksh also output four fields, like
bash.
However, this is what POSIX says:
3.b. Each occurrence in the input of an IFS character that is not
IFS white space, along with any adjacent IFS white space, shall
delimit a field, as described previously.
We ignore all the white space stuff (since we are not using white
spaces), and thus:
Each occurrence in the input of an IFS character shall delimit a field.
In zsh each occurrence of a comma does delimit a field (4 commas, 5
fields), which to me is what POSIX says should happen.
So in this particular case it seems zsh is complying with POSIX (even
in zsh mode), and all other shells are not.
So there's no bug (at least in zsh), I just wanted to let you know
what I found, and see if you agreed with my interpretation.
Cheers.
[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05
--
Felipe Contreras
next reply other threads:[~2023-03-30 11:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 11:11 Felipe Contreras [this message]
2023-03-30 12:05 ` Lawrence Velázquez
2023-03-30 12:10 ` Discrepancy in IFS handling (zsh is *not* " Felipe Contreras
2023-03-30 14:49 ` Ray Andrews
2023-03-30 15:09 ` Felipe Contreras
2023-03-30 15:31 ` Ray Andrews
2023-03-30 14:57 ` Bart Schaefer
2023-03-30 15:34 ` Felipe Contreras
2023-03-31 20:16 ` Discrepancy in IFS handling (zsh is " Felipe Contreras
2023-04-01 19:20 ` Lawrence Velázquez
2023-03-31 16:38 ` Thomas Paulsen
2023-03-31 20:18 ` Felipe Contreras
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=CAMP44s31HWYdR+Qn7w7yxzsboheEf_6xFv4yv6qGS8NBT_pqhA@mail.gmail.com \
--to=felipe.contreras@gmail.com \
--cc=zsh-users@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).