On Sun, Nov 6, 2016 at 3:46 PM, Chet Ramey <chet.ra...@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.

Reply via email to