zsh-users
 help / color / mirror / code / Atom feed
* Discrepancy in IFS handling (zsh is POSIX compliant)
@ 2023-03-30 11:11 Felipe Contreras
  2023-03-30 12:05 ` Lawrence Velázquez
  2023-03-31 16:38 ` Thomas Paulsen
  0 siblings, 2 replies; 12+ messages in thread
From: Felipe Contreras @ 2023-03-30 11:11 UTC (permalink / raw)
  To: Zsh Users

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


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

end of thread, other threads:[~2023-04-01 19:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 11:11 Discrepancy in IFS handling (zsh is POSIX compliant) Felipe Contreras
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

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).