[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: |
Wed, 14 Apr 2021 07:28:43 +0800 |
On Wed, Apr 14, 2021 at 6:37 AM L A Walsh <bash@tlinx.org> wrote:
> So echo ${a[@]} = expansion of all, but
> unset a[@] would only delete 1 element w/key '@'....
> how do I echo 1 element with key '@'
Indeed we can only quote:
a['@']=1234
echo "${a['@']}"
unset "a['@']"
Or have it interpreted as a value of a variable:
key=@
a[$key]=1234
echo "${a[$key]}"
unset 'a[$key]'
The current behavior of unset already does it right because unset is
not a keyword and not a special builtin like local. Quoting and
re-evaluation are necessary so it gets evaluated well like how it is
evaluated during expansion and assignment.
I think I finally can say I'm against unset being defaulted to the
behavior of assoc_expand_once. It's oversimplified, adds
inconsistencies, and will majorly break scripts.
The only change I'd want is have `unset 'a[@]'` only unset the
elements and not the array itself.
--
konsolebox
- Re: Changing the way bash expands associative array subscripts, (continued)
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/18
- 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 <=
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/13
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 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, Chet Ramey, 2021/04/08
Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/08