Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] (?) typeset array[position=index]=value

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

> 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


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