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: Mon, 24 Oct 2016 09:25:52 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

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.

-- 
``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]