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: Mon, 19 Apr 2021 06:25:58 +0800

On Mon, Apr 19, 2021 at 6:01 AM Chet Ramey <chet.ramey@case.edu> wrote:
> > Yes, but if `unset' is defaulted to `assoc_expand_once' behavior while
> > indirect expansions and namerefs aren't changed, users still need to
> > do two different ways of quoting: « unset "a[$key]" » versus «on
> > iref='a[$key]'; echo "${!iref}" » and « declare -n nref='a[$key]';
> > echo "$nref" ».
>
> I just don't see this as the same problem you do. Assigning a string value
> to a variable is not the same thing as expanding a variable's value.

There would be if the referring function also deletes the parameter.

unset "$iref"

declare +n nref
unset "$nref"

> > Or another solution might be introducing special syntactic treatment
> > of `unset' arguments:
>
> Nope, not going to go that way without much better reasons than I've seen
> so far.

There's less reason to choose a complicated solution that adds
thinking overhead, adds inconsistencies and breaks scripts.

Making unset skip default word expansion on tokens that pass
valid_array_reference () is much simpler.

-- 
konsolebox



reply via email to

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