Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: unset arbitrary associative array element
- X-seq: zsh-workers 43274
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- Subject: Re: unset arbitrary associative array element
- Date: Sun, 12 Aug 2018 07:06:57 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=Ook94T6cmDjUcE388aoaRkuqT3Wu/mzbtj4bw+icbuE=; b=tgRE4v7yJTx9ioyRNFPqWS2AYroQU421UWB/sXhXQVn5cYMU8porxU3cjDBxLvNmu6 ggWe4ODN3UrFer44wvIR3Nl0pR605YEU93jw1IN/1SKWsWaWfqcoRyhtxSOG9lCE0JF1 xLe0/VZPo4dqkOdBksiVJMX4NwiGCh8qgCRPj58CpArk6YLgGA2yYRxvnoCiLYtpyKEq 1L+jg18qGRO+3GAWru6rBBD+1zn2PO4PEt+X8cVdO7HQ5WL7+/Rjj0r2sKhdMNFJD6eh /bZ3PUjsMgKAwce/vXarddC94VGMWyCJn1dzWIINj7JNIOvXAlSeN07mIdFeU1j8C5ce ZD1g==
- In-reply-to: <CAKc7PVDNipoD=1FZQXF5qz2wf=nOMP-foabaWVNp+zBWanoK4w@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180811112226.tiscidxlc7edxqmg@chaz.gmail.com> <CAKc7PVDNipoD=1FZQXF5qz2wf=nOMP-foabaWVNp+zBWanoK4w@mail.gmail.com>
2018-08-11 16:55:33 +0200, Sebastian Gniazdowski:
> On Sat, 11 Aug 2018 at 13:22, Stephane Chazelas
> <stephane.chazelas@xxxxxxxxx> wrote:
> > Is there any other way, other than recreating the full array
> > with something like:
> >
> > hash=("${(@kv)hash[(I)^$key]}") # untested
>
> I once reported some unset-key impossibilities, and Bart and Peter
> added a (b) flag. Maybe it helps here too. Could someone recall what
> this flag does?
[...]
Thanks Sebastian,
unset "hash[${(b)key}]"
does work for keys with "]" or "\" and for characters that
contain bytes 0x5c/5d, but not for the empty key.
Sounds like that problem can be fixed by allowing
unset 'hash[]'
like in ksh93. It would also be useful to allow
hash[]=value
as well (k=; hash[$k]=value and hash+=('' value) do work).
As for the characters with byte 0x5c in their content, that's a
more general problem.
If you want to test, try for instance:
LC_ALL=zh_HK.big5hkscs luit
And within luit:
hash[α]=foo
# and so on
α in BIG5 or BIG5-HKSCS is encoded as 0xa3 0x5c, 0x5c also being
the encoding of \. ${(b)key} for key='α' expands to α\ (0xa3
0x5c 0x5c).
That trailing 0x5c in the encoding of α is taken as a backslash
in many contexts in zsh.
Beside BIG5 and BIG5-HKSCS, GBK and GB18030 charsets also have
characters that contain 0x5c.
It may not be worth fixing if Chinese/Thai people have all
switched to UTF-8 by now.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author