Geoff Clare <g...@opengroup.org> wrote, on 10 Aug 2018:
>
> Robert Elz <k...@munnari.oz.au> wrote, on 10 Aug 2018:
> >
> >     set --; A=;  for x in a $A b $* c; do printf "[%s]\n" "$x"; done
> > 
> > needs to produce
> > 
> >     [a]
> >     [b]
> >     [c]
[...]
> >     A=: ; IFS=: ;   for x in a $A b; do printf "[%s]\n" "$x"; done
> > needs to produce
> >     [a]
> >     []
> >     [b]

> The best way forward might be for someone familiar with the source
> of ksh93 or bash (or another popular shell) to look at how the shell
> actually decides whether the complete expansion produces nothing or
> a single empty field.
> 
> It may be that the place to document it is not in 2.6 but in one
> of the individual expansions (e.g. Field Splitting), so for now
> I'll leave bugnote 4082 saying to delete it.

Actually, I think the existing description of Field Splitting handles
it correctly.

It may be easier to see if you consider:

set --; A="  ";  for x in a $A b $* c; do printf "[%s]\n" "$x"; done

Applying "any sequence of <space>, <tab>, or <newline> characters at
the beginning or end of the input shall be ignored and any sequence of
those characters within the input shall delimit a field" to $A (after
parameter expansion) results in the space characters being ignored, and
then there are no non-IFS characters left to constitute a field, and
no IFS characters left to delimit a field, so the result is no fields.

(The $* isn't an issue because parameter expansion produces "one field
for each positional parameter that is set".  There are no positional
parameters set, so there are no fields.)

With:

A=: ; IFS=: ;   for x in a $A b; do printf "[%s]\n" "$x"; done

applying "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" results in the ':' delimiting (terminating) a field
and thus the result is one empty field.

So I think just deleting that paragraph, as bugnote 4082 currently has
it, is the right thing to do.

-- 
Geoff Clare <g.cl...@opengroup.org>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England

Reply via email to