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]

[...]
> So, perhaps back to something more like the proposed text for
> this paragraph in note 4071, but changed from "an empty"
> to "a single empty" (field) and that would work?
> 
> 
> Hmm, even that is not right, as as
>       A=: ; IFS=: ;   for x in a $A b; do printf "[%s]\n" "$x"; done
> needs to produce
>       [a]
>       []
>       [b]
> and in that case field splitting did produce a single empty
> field...

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.

> There is one more problem (conflict) while we are here ...
> 
> 2.5.2 says (of field splitting)  (lines 74850-2, page 2350)
> 
>   Field splitting as described in Section 2.6.5 would be performed if
>   the expansion were not within double-quotes (regardless of
>   whether field splitting would have any effect; for example, if IFS is null).
> 
> where the "for example" is the important part ... that is, this implies
> that a null IFS does not prevent field splitting being performed, rather
> that would simply be treated as a case like IFS=%  and there are no
> '%' characters in the word, so the field splitting has no effect.
> 
> But in the 4 step procedure of 2.6 (step 2) it says ...   (lines 75002-3
> page 2353)
> 
>   Field splitting (see Section 2.6.5) shall be performed on the portions
>   of the fields generated by step 1, unless IFS is null.
> 
> which is quite clear that field splitting does not happen when IFS is
> null, which is backed up by section 2.6.5, step 2 (line 75273, page 2359)
> 
>    If the value of IFS is null, no field splitting shall be performed.
> 
> nb: not "has no effect" or similar, but "no field splitting shall be
> performed".
> 
> I think this one also needs fixing, and rather than change 2.5.2
> I suspect it is simply better to drop the "unless IFS is null" from
> line 75003, and change line 75273 to say
> 
>    If the value of IFS is null, field splitting has no effect
> 
> (or perhaps "makes no change" instead of "has no effect")
> 
> in order to make it clear that IFS being null does not stop
> field splitting being attempted, and does not avoid the context
> being one where "field splitting would be performed" (which is
> relevant other places too I think) but simply results in field
> spliiting being a no-op (equivalent to not being performed,
> without the side effects of that.)

Agreed.  I've added these changes to note 4082.

> Lastly (and trivially), in your new proposed resolution, that is,
> in note 4082, the first reference to a change in line 74998 should
> be line 74992  (the second reference to line  74998 is correct).

Thanks - I've fixed that.

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

Reply via email to