On 11/1/16 5:57 AM, Dan Douglas wrote:
> On Mon, Oct 24, 2016 at 8:25 AM, Chet Ramey <chet.ra...@case.edu> wrote:
>> On 10/21/16 5:41 PM, L. A. Walsh wrote:
>>> On 4.3 and earlier, at least on arrays, one could have
>>> the illusion of this working w/o complaint -- and returning
>>> 0 when the array was 0-len or unset, or the array length,
>>> otherwise:
>>>
>>>
>>>  echo ${#array[@]:-0}
>>>
>>> But I note it only seemed to work in arrays, and in 4.4 gets a
>>> syntax error:
>>>
>>>  echo ${#array[@]:-0}   bash: ${#array[@]:-0}: bad substitution
>>
>> Because it is a syntax error, and if it were not it would be ambiguous.
>> The ${param:-word} word expansion takes a parameter, not another word
>> expansion, as the object to be expanded.
> 
> On a possibly related note, would you consider adjusting +, :+, -, :-,
> as in "${var[@]+word}" to align with the meaning of [[ -v var[@] ]] as
> discussed in https://lists.gnu.org/archive/html/bug-bash/2014-11/msg00099.html
> ? 

There's not a compelling reason to break backwards compatibility or to be
unnecessarily incompatible with other shells that implement that construct,
like ksh93.

Chet

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

Reply via email to