zsh-users
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: "Lawrence Velázquez" <larryv@zsh.org>, "Zsh Users" <zsh-users@zsh.org>
Subject: Re: Discrepancy in IFS handling (zsh is *not* POSIX compliant)
Date: Thu, 30 Mar 2023 09:34:25 -0600	[thread overview]
Message-ID: <CAMP44s1uReXNzZduaXwhMxiw8fnSLwVTv8nfDB15CkaNw9pEMw@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7bJV2wkJcrS2cPBMgZKr=oq8qC38hRAWtgubefmrozQgg@mail.gmail.com>

On Thu, Mar 30, 2023 at 8:58 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> This has been discussed before, e.g. workers/48498 about 2 years ago.
> There are even xfail tests in E03posix.ztst making note of it, added
> in workers/48560.

OK. But I don't see much of a conclusion.

Do you believe POSIX says these should be two fields? IFS=: str="a:b:"

POSIX does say the delimiter shall be considered a field terminator,
but str="a" has no field terminator, does that mean there's no valid
field? I understand from the point of view of processing strings in a
language like C it makes sense to consider an unterminated field
valid, but that's an assumption, POSIX doesn't specify that. It could
be considered that "return 0" is not a valid field (if it doesn't end
in a semicolon).

Or, one could assume POSIX meant in the case of str="a" the end of
string shall be considered an implicit terminator, but in that case
"a:b:" would have three fields, therefore making the terminators
identical to separators. In which case zsh is actually compatible with
POSIX.

So the options are:

1. zsh is compatible with POSIX
2. bash and other shells are compatible with POSIX
3. All are compatible since POSIX isn't clear

If POSIX isn't clear, then there's not much reason to implement
behavior just because other shells do it. But if you believe POSIX is
clear that the behavior of other shells is the correct one, then it
might make sense to implement it in sh mode.

Cheers.

-- 
Felipe Contreras


  reply	other threads:[~2023-03-30 15:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 11:11 Discrepancy in IFS handling (zsh is " 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 [this message]
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=CAMP44s1uReXNzZduaXwhMxiw8fnSLwVTv8nfDB15CkaNw9pEMw@mail.gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=larryv@zsh.org \
    --cc=schaefer@brasslantern.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).