Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH (not final)] (take three?) unset "array[$anything]"
2021-06-03 09:54:41 +0100, Peter Stephenson:
> > On 03 June 2021 at 07:12 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > So, we're probably in pretty safe territory with either choice but in
> > terms of backwards compatibility the stripquote version is slightly
> > ahead.
>
> I'd be in favour of this. I agree with the consensus that the current code
> is not really usable for difficult cases, so some degree of incompatibility
> is warranted.
[...]
If I understand correctly, the "stripquote" variant is the one
where the user can do:
unset 'hash["foo"]'
unset "hash['']"
unset "hash[${(qq)key}]"
That is where quotes are parsed and removed but otherwise
serve no purpose.
IMO, that just confuses things even more.
That hardly helps with backward compatibility as users who did
work around the previous behaviour will still have to adapt
their work around, and those who didn't (who did unset
"hash[$key]") will have their code choke on even more characters
(", $, ' in addition to the previous ones, and likely more
confusing behaviour when there are unmatched quotes or ()).
It also deviates even more from the other places that take
lvalues causing potential confustion. hash["foo"]=x or read
'hash["foo"]' set the element of key "foo" (quotes included) not
foo.
To me, acceptable options would be the "literal" one, or add
another quoting flag (maybe "bb"?) that quotes in the manner
currently expected by unset so people can use
unset "hash[${(bb)key}]" (but unfortunately not read
"hash[${(bb)key}]" for which $, ` also need to be escaped with
backslash so that bb flag would only be useful for unset), or
unset -k "$key" hash, or a new option à la bash.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author