[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IFS field splitting doesn't conform with POSIX

From: Felipe Contreras
Subject: Re: IFS field splitting doesn't conform with POSIX
Date: Thu, 30 Mar 2023 11:35:08 -0600

On Thu, Mar 30, 2023 at 9:52 AM Emanuele Torre <torreemanuele6@gmail.com> wrote:
> On Thu, Mar 30, 2023 at 07:51:59AM -0600, Felipe Contreras wrote:
> > But you can't replicate 'a,b' that way, because b does not have a
> > terminator. Obviously we'll want 'b' as a field, therefore one has to
> > assume either 1) the end of the string is considered an implicit
> > terminator, or 2) the terminator in the last field is optional.
> > Neither of these two things is specified in POSIX.
> >
> > If we consider 1) the end of the string is considered an implicit
> > terminator, then 'a' contains a valid field, but then 'a,' contains
> > *two* fields. Making these terminators indistinguishable from
> > separators.
> I repeatedly disputed this interpretation on IRC by saying that your
> reasoning to come to this conclusion is that "',' can terminate a field,
> and the end of the string can terminate a field, so ',' at the end is
> two terminators".

I did not come to a conclusion, and that is not my reasoning. In IRC
you never paid attention to what I was actually saying, so here you
are attacking a straw man.

> If we extend that reasoning 'a , b' with IFS=' ,' should be split into
> four fields because individually ' ', ',', ' ', and the end of string
> could all terminate a field.

IFS white space characters shall be interpreted differently. That's
clear from the specification.

> You refuse to acknowledge that it does not make sense to claim that a
> comma at the of the string MUST yield an empty last field just because a
> ',' and the "end of string" terminator individually can terminate a
> field.

That is not my claim.

> The correct interpretation is that a field is implicitly terminated by
> the end of the string if it is not explicitly terminated by a
> terminator.

Nowhere in the specification does it say that.

> How can you say that the current implementation that bash, dash, etc.
> use is not compliant to the POSIX specification?

I have never said that.

> If that is not what you are claiming, how do you think that bash's
> implementation of field splitting is not compatible with POSIX
> definition since you did not mention it as a possible interpretations?

I did not say I think that.

My suggestion is that you forget the IRC discussion and focus on what
is being said here.

Felipe Contreras

reply via email to

[Prev in Thread] Current Thread [Next in Thread]