[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Changing the way bash expands associative array subscripts
From: |
Ilkka Virta |
Subject: |
Re: Changing the way bash expands associative array subscripts |
Date: |
Tue, 6 Apr 2021 19:19:37 +0300 |
On Tue, Apr 6, 2021 at 6:53 PM Greg Wooledge <greg@wooledge.org> wrote:
> In that case, I have no qualms about proposing that unset 'a[@]' and
> unset 'a[*]' be changed to remove only the array element whose key is
> '@' or '*', respectively, and screw backward compatibility.
>
That also seems to be what Ksh and Zsh do.
$ zsh -c 'k=@; typeset -A a=("$k" at foo 123); typeset -p a; unset "a[$k]";
typeset -p a;'
typeset -A a=( @ at foo 123 )
typeset -A a=( foo 123 )
$ ksh -c 'k=@; typeset -A a=([$k]=at [foo]=123); typeset -p a; unset a[$k];
typeset -p a;'
typeset -A a=([@]=at [foo]=123)
typeset -A a=([foo]=123)
Both also have issues with unset a[$k] when k="x] b[y", btw.
What konsolebox said about a[$k]=() works in my Zsh for indexed arrays, but
not associative ones.
(It replaces an array slice, so can also be used to insert elements in the
middle.)
- Re: Changing the way bash expands associative array subscripts, (continued)
Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/05
Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Ilkka Virta, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 2021/04/06
- Re: Changing the way bash expands associative array subscripts,
Ilkka Virta <=
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Dennis Williamson, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/06
Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/06
Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 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, Greg Wooledge, 2021/04/08
Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/08