Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] (?) typeset array[position=index]=value
- X-seq: zsh-workers 48976
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] (?) typeset array[position=index]=value
- Date: Tue, 1 Jun 2021 06:32:35 +0100
- Archived-at: <https://zsh.org/workers/48976>
- In-reply-to: <CAH+w=7bVn2LiTsq194GjshVSOCSib7t4T=uZQ2ZvUGu6Z2XoPw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- References: <20191216212706.i3xvf6hn5h3jwkjh@chaz.gmail.com> <20191217073846.4usg2hnsk66bhqvl@chaz.gmail.com> <20191217111113.z242f4g6sx7xdwru@chaz.gmail.com> <2ea6feb3-a686-4d83-ab27-6a582424487c@www.fastmail.com> <20200101140343.qwfx2xaojumuds3d@chaz.gmail.com> <20210430061117.buyhdhky5crqjrf2@chazelas.org> <CAH+w=7bHxSbFr60ZU0+oZ6+qEejhfBYTzvL7=aXadY5XzWtSzw@mail.gmail.com> <20210505114521.bemoiekpophssbug@chazelas.org> <CAH+w=7ZqE2DnxpHhvCjZnXB4A1vJ=EKB2fpWyUMaZX0VYqU9kg@mail.gmail.com> <CAH+w=7bVn2LiTsq194GjshVSOCSib7t4T=uZQ2ZvUGu6Z2XoPw@mail.gmail.com>
While we're at it, could we fix:
assoc[]=x
unset 'assoc[]'
etc.
The former can be worked around with assoc[${-+}]=x or
assoc+=('' x), the latter not AFAICT.
See also
worker:43269
https://unix.stackexchange.com/questions/626393/in-zsh-how-do-i-unset-an-arbitrary-associative-array-element/626529#626529
unset -k "$key" assoc_or_array
or:
assoc[$key]=()
Would probably make sense to fix the issue with escaping \ and ]
bytes in there unless we're happy to break backward
compatibility and make unset "assoc[$key]" work whatever the
value of $key (unset 'assoc[f\]oo]]' for unset the element of
key 'f\]oo]' for instance)
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author