[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
- Re: Changing the way bash expands associative array subscripts, (continued)
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/13
- Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/13
- Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/13
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/15
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/15
- Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/16
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/18
- Re: Changing the way bash expands associative array subscripts,
konsolebox <=
- Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/19
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 2021/04/09
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/09
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/12
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/12
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, L A Walsh, 2021/04/13
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/13