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: konsolebox
Subject: Re: Changing the way bash expands associative array subscripts
Date: Fri, 9 Apr 2021 06:35:08 +0800

On Fri, Apr 9, 2021 at 3:21 AM Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 4/6/21 11:42 AM, konsolebox wrote:
>
> > Or maybe just completely avoid this new behaviors and allow another
> > way to unset an element of an array.
> >
> > a[$key]=()
> > a[@]=()
>
> While this is mildly interesting syntax, and currently an error, I don't
> think we need another new way to do this.

But it has pretty good advantages:

1) Existing scripts that double-quote unset arguments internally don't
break. This is a big change which would prevent elements to be unset,
and could be expensive. It also means less confusion and warnings on
the usage of unset with respect to different versions.
2) The setting and unsetting of an element have clear similar
interpretation and syntax, with no surprises.
3) A new feature that replaces an element with multiple values.
4) Not another compatibility option to add, and internal codes to keep
just to keep compatibility.  Means less complexity.
5) If "LinkedHashMap" is implemented, the order in which
"${assoc_var[@]}" expands becomes more predictable.
6) Some Bash-Zsh users might like it.

-- 
konsolebox



reply via email to

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