[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: |
Wed, 9 Nov 2016 13:22:26 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
On 11/7/16 4:49 AM, Dan Douglas wrote:
> On Sun, Nov 6, 2016 at 3:46 PM, Chet Ramey <chet.ramey@case.edu> wrote:
>> On 11/1/16 5:57 AM, Dan Douglas wrote:
>>> 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.
>
> I kind of doubt anybody would know what to expect with them. :+ and :-
> are particularly weird (they don't quite have to do with testing for
> defined variable admittedly).
This is probably true. I think all the shells with arrays try to treat
${a[@]} in the same way as $@, which gets strange in a "scalar" context.
There was a pretty extensive discussion of the $@ issue on the austin-
group mailing list, which revealed big differences in how shells expand
$@ in a "non-list" context. I think those differences are reflected in
how those shells expand ${a[@]}.
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/