bug-bash
[Top][All Lists]
Advanced

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

Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#le


From: Chet Ramey
Subject: Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}
Date: Sun, 6 Nov 2016 16:46:43 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 11/1/16 5:57 AM, Dan Douglas wrote:
> On Mon, Oct 24, 2016 at 8:25 AM, Chet Ramey <address@hidden> 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 address@hidden:-0}
>>>
>>> But I note it only seemed to work in arrays, and in 4.4 gets a
>>> syntax error:
>>>
>>>  echo address@hidden:-0}   bash: address@hidden:-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 "address@hidden" to align with the meaning of [[ -v address@hidden ]] 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    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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