From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13294 invoked by alias); 12 Aug 2018 06:07:04 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43274 Received: (qmail 28166 invoked by uid 1010); 12 Aug 2018 06:07:04 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f54.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.82.54):SA:0(-1.9/5.0):. Processed in 0.978346 secs); 12 Aug 2018 06:07:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state: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=jOOMIMS50UhmdeQHeeDHoD9yB1rrBOpvJvsnuOQUZRfxrVfNzdGma0VO/NCRZdO3vL xKGk/M1MRjC0f21bB5kAAg6Q4kBCRYvYJYNWLjjiDQFCKWNF4UX1Ryh9WA7DTO7ppX96 kzrlNTwg1jhF5K9ZplvoMHXNqj4DWtlIhOjfdYgo/6r85K/ZYEhO2wmHtiuE+zX425vj GI0w+RDocAtOWdO+geCVzatXN9AGqzvixxHfIKwa8tDRjQRBCeSdU//Q7MElEHUjI05h CuiGM+HB3L7CsRnSHujr1oJfh+oSYJVxRgDQvLzdqjki3rCtWcvfsoTRsU8l9R2Jt4e8 ZGGg== X-Gm-Message-State: AOUpUlGS7SKNsI+8FyfEwO+SdVoxbe11pwipjzJTl9A0/yNibhWZYKBf sev8cT7S7S/GjLZvGSCxRUtiR55s5Z0= X-Google-Smtp-Source: AA+uWPzw1vXZDLj/9Cz2eveCNs1PuMpwlWRlc6l5rDItG4pgsoLkd4Ib7CnmXw9fIj9d5ZGmfdSpbg== X-Received: by 2002:a1c:385:: with SMTP id 127-v6mr5293801wmd.92.1534054019241; Sat, 11 Aug 2018 23:06:59 -0700 (PDT) Date: Sun, 12 Aug 2018 07:06:57 +0100 From: Stephane Chazelas To: Sebastian Gniazdowski Cc: Zsh hackers list Subject: Re: unset arbitrary associative array element Message-ID: <20180812060657.3ipyrg4xyxjp3b3e@chaz.gmail.com> Mail-Followup-To: Sebastian Gniazdowski , Zsh hackers list References: <20180811112226.tiscidxlc7edxqmg@chaz.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20171215 2018-08-11 16:55:33 +0200, Sebastian Gniazdowski: > On Sat, 11 Aug 2018 at 13:22, Stephane Chazelas > 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