bug-bash
[Top][All Lists]
Advanced

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

Re: Changing the way bash expands associative array subscripts


From: Greg Wooledge
Subject: Re: Changing the way bash expands associative array subscripts
Date: Tue, 6 Apr 2021 11:52:22 -0400

On Tue, Apr 06, 2021 at 06:34:21PM +0300, Ilkka Virta wrote:
> $ declare -A a=([foo]=123 [bar]=456)
> $ unset 'a[@]'
> $ declare -p a
> bash: declare: a: not found
> 
>  i.e. both remove the whole array, not just the contents.

Huh, so it does.  I didn't know that.

In that case, I have no qualms about proposing that unset 'a[@]' and
unset 'a[*]' be changed to remove only the array element whose key is
'@' or '*', respectively, and screw backward compatibility.  The current
behavior is pointless and is nothing but a surprise landmine.  Anyone
relying on the current behavior will just have to change their script.



reply via email to

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