bug-bash
[Top][All Lists]
Advanced

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

Re: "${x-"$@"}" expansion


From: Chet Ramey
Subject: Re: "${x-"$@"}" expansion
Date: Sun, 1 May 2016 19:29:54 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.0

On 4/26/16 3:03 PM, Grisha Levit wrote:
> This behavior seems very strange.  This example is with $@ but it seems the
> same for address@hidden
> 
> The manual says for ${parameter:-word}:
> 
>> If parameter is unset or null, the expansion of word is substituted.
> 
> In this case, $@ is expanded as if it was quoted (even if 'word' is not
> quoted) and the outer quotes do no serve to quote the expansion of 
> address@hidden
> 
> $ set -- '1 1' '2 2'; unset x
> $ v=( "address@hidden" ); declare -p v
> declare -a v=([0]="1 1" [1]="2 2")
> 
> In this case though, the expansion is an empty string rather than nothing
> so it seems that a different set of rules is being followed:

Thanks for the report.  This was discussed by the austin group back in 2014
and resulted in Posix interpretation 888.

> 
> $ set --
> $ v=("$@"); declare -p v          # obviously
> declare -a v=()
> $ v=( "address@hidden@}" ); declare -p v   # ?
> declare -a v=([0]="")
> 
> The following is strange, in light of the above:
> 
> $ v=("address@hidden@address@hidden"); declare -p v
> declare -a v=()

It took longer to track down and fix this than any of the nameref issues.
This will be fixed in bash-4.4.

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



reply via email to

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