[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: |
Dan Douglas |
Subject: |
Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length} |
Date: |
Mon, 7 Nov 2016 03:49:12 -0600 |
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).
a[0]= a[1]=; echo "${a[@]:-y}"
ksh: <y> mksh: < > bash: < >
a[1]=; echo "${a[@]:-y}"
ksh: <y> mksh: <y> bash: <>
a[0]= a[1]=x; echo "${a[@]:-y}"
ksh: <y> mksh: < x> bash: < x>
a[0]= a[1]=x; echo ${a[@]:+y}
ksh: <> mksh: <y> bash: <y>
The main difference between `[[ -v a[@] ]]` and ${a[@]+} / ${a[@]-} is
just with hidden locals I think. I suppose that's not so bad unless
I'm forgetting something.