bug-bash
[Top][All Lists]
Advanced

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

Re: [BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields


From: Chet Ramey
Subject: Re: [BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields
Date: Mon, 27 Feb 2017 15:03:28 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.7.1

On 2/27/17 12:57 PM, Martijn Dekker wrote:
> Op 24-02-17 om 21:20 schreef Grisha Levit:
>> XRAT C.2.5 : Special Parameters [1] specifically addresses the case of
>> ${unset_var-$*}.  The following example is provided:
>>
>> set "abc" "def ghi" "jkl"
>> IFS='' # null
>> unset var
>> printf '%s\n' ${var-$*}
>>
>> abcdef ghijkl
>>
>> ..which seems to contradict your proposed expected output.
> 
> Hmm. I'm pretty sure that's a bug in their provided examples.
> 
> First, bash acts differently for unquoted $* and unquoted ${var-$*} (or
> ${1+$*}, etc). Given an unset 'var', these should act identically. If
> they don't, that's a bug either way.
> 
> Second, the cited example is contrary to the specification, which says:
> "Expands to the positional parameters, starting from one, initially
> producing one field for each positional parameter that is set. When the
> expansion occurs in a context where field splitting will be performed,
> any empty fields may be discarded and each of the non-empty fields shall
> be further split as described in Field Splitting. [...]"
> 
> Well, the expansion occurs "in a context where field splitting will be
> performed" because it is unquoted (the fact that IFS happens to be null
> is neither here nor there; its value or lack thereof has no bearing on
> the lexical context). So the non-empty fields, having been generated,
> "shall be further split as described in Field Splitting", which, given
> that IFS is null, is a no-op.

If you think you have a winning argument, initiate a new discussion with
the Austin Group.  You might want to dig up the mail archives from
October, 2014 and look at the discussion that preceded interpretation 888.

You might also prepare a counter to the argument that at the time the
$* on the right side of the parameter expansion is expanded, the rules
in force are detailed in 2.6.2 ("word shall be subjected to tilde
expansion, parameter expansion, command substitution, and arithmetic
expansion"), and word splitting isn't listed. I think that came up before.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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