Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] (?) typeset array[position=index]=value
- X-seq: zsh-workers 48979
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] (?) typeset array[position=index]=value
- Date: Tue, 1 Jun 2021 09:05:13 -0700
- Archived-at: <https://zsh.org/workers/48979>
- In-reply-to: <20210601053235.b4junj6muuwegl7b@chazelas.org>
- List-id: <zsh-workers.zsh.org>
- 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> <20210601053235.b4junj6muuwegl7b@chazelas.org>
On Mon, May 31, 2021 at 10:32 PM Stephane Chazelas
<stephane@xxxxxxxxxxxx> wrote:
>
> While we're at it, could we fix:
Wow, that thread from 2016 sort of died out in the middle, at
workers/37933. Thanks for reminding me of that thread, though, I
should at least examine whether getasg() ought to be using
parse_subscript() even though the corresponding parse.c block is using
skipparens().
> assoc[]=x
> unset 'assoc[]'
> etc.
>
> The former can be worked around with assoc[${-+}]=x or
> assoc+=('' x), the latter not AFAICT.
The former can also be done with
assoc[(e)]=x
Whereas most subscript flags are meaningless for unset, we might
consider supporting (e) there. I'm not sure whether that would fully
address the problem with the other characters, though.
The issue with the empty key seems merely to be that the subscript
validity test for associative arrays never changed from the one for
plain arrays.
> [...] 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)
Hm, I'm not sure what backward-compatibility would be broken? Do you
mean that scripts that already have work-arounds for the current issue
might stop working?
That's sort of why I'm thinking about (e). If that flag had to be
present in order to get the "whatever the value of $key" behavior, old
workarounds would be unchanged.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author