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:01:10 -0400

On Tue, Apr 06, 2021 at 11:28:13PM +0900, Koichi Murase wrote:
> 2) we
> can distinguish the erasure of the element associated with key=@
> `unset -v a[$key]' from the entire array erasure `unset -v a[@]'.

As a counter-proposal, Chet could entirely remove the special meaning
of unset 'a[@]' and introduce a new option to unset which would take
its place.  It appears -a is not yet used, so that would be a good pick.

Under this proposal, unset 'a[@]' would only remove the single element
whose key is '@', and unset -a a would remove all the elements of the
array.

I don't know whether any scripts actually use unset 'a[@]' to clear all
the keys out of an array, but this change would obviously break backward
compatibility if any such scripts exist.  Therefore I only bring it up
because this whole thread is about introducing new behaviors that break
compatibility.



reply via email to

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