From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24875 invoked from network); 2 Jun 2021 14:20:44 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Jun 2021 14:20:44 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1622643644; b=dkBlNPzU5o0HpRLd0knaiGOBtmkrnDgQLsrtH558mlOODYGlSaSWwfSe6O0JOzUcQVKDhF4xru hurwqCy6ayVHHUn8lxVMhthpl4ub7Jvcg1Vuo2k7s4BbL5zwfW/3ZP/AhnFKpUusy7YuBYpLcB letx1HJr8yosQzAFdZk4nfnOdRfwLco48q22gGMrOZ5SRQ+EpWfh/rzN7/vdth14NJwTyS3mRX SHBlm8OoO03rIdqh7i71wwYgMJztCP8zQRbzSnAxi+F9TXgY1dULVzzLa44Jo6CeRUY9aJFta1 /SXZVUy9aYUi9McJNSMFDKVaJ6PK3nEqwDx0Z7x4SO7Npg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay2-d.mail.gandi.net) smtp.remote-ip=217.70.183.194; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1622643644; bh=1xVPTpShtEYYKNInaQtX7o8ns4IT98PRQI7hDNWS7jM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature; b=CGHt+opiwuER5rBeOCzhpeY3PybGr3AFK5FwcjhJyFTEtgLvBe3v3i2wkPBko0XPfmLPMJ13kF EaXpZY9W/Nm1tPdXfM7sfDMIKmQpU3r6M+q5+P3QYwK/MTq5dC5OtCOZxzPFgpdrX+257N1U3W znEcB3Dm2ZsqtLF7J2Ik7+vuwzvXnS5Lj4aWn3aDPvTRPd+awUWA0LP7OEP+aiiSlvf1IC8mVW mafRwM8zYhj/JsI8FUEp8TRyMFNQZ7RIAn+EacVmcFDJHc+iEqn0BMT/w1FkkQukRaMsj32SAz hq2SYM+dHBbWPY32xMomMBzspugHOokrN549blNNWyB8Xg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=YupRqDhOeqcvk3poCsF7tmzHvYixCQI/mfCn3cpIYKY=; b=VKrmUdQskisZ7zXfFIr4r2dl3Q L+BA6Ww0xUGQXhJlINnQTbnOMHAWYJPu7YkLGAAJGBcJGpdJ9qk9PREnnm5Vvx9NHTmo0wdl5pBYB Neo6srtWJrobH0fE8ML+pD493m8B5c8S9/6F29QbnZQXjzbr5pm3EBaB1syi2SDfvJ+9RDTi8UkM/ QGHCwiQns42vcK+Rc3+jz3iaI+oLpuSt6CCNCNYrL89sUnFLpIdEHYQoOrxQtGAsdio0wu22HdO2b YntGnV3V1GxJxqVNVMLSKJM3jli9lSRCjnZAF7BCATsypXCY6gjpLmVoVR0IZGheV1jrKWHjIixPQ bupBvW0A==; Received: from authenticated user by zero.zsh.org with local id 1loRjg-000GkF-Cl; Wed, 02 Jun 2021 14:20:44 +0000 Authentication-Results: zsh.org; iprev=pass (relay2-d.mail.gandi.net) smtp.remote-ip=217.70.183.194; dmarc=none header.from=chazelas.org; arc=none Received: from relay2-d.mail.gandi.net ([217.70.183.194]:40299) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1loRj6-000GOG-3C; Wed, 02 Jun 2021 14:20:09 +0000 Received: (Authenticated sender: stephane@chazelas.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id B26724001C; Wed, 2 Jun 2021 14:20:06 +0000 (UTC) Date: Wed, 2 Jun 2021 15:20:05 +0100 From: Stephane Chazelas To: Daniel Shahaf Cc: zsh-workers@zsh.org Subject: Re: [PATCH] (?) typeset array[position=index]=value Message-ID: <20210602142005.b5tw2hj2c6q3psqv@chazelas.org> Mail-Followup-To: Daniel Shahaf , zsh-workers@zsh.org References: <20200101140343.qwfx2xaojumuds3d@chaz.gmail.com> <20210430061117.buyhdhky5crqjrf2@chazelas.org> <20210505114521.bemoiekpophssbug@chazelas.org> <20210601053235.b4junj6muuwegl7b@chazelas.org> <20210602091145.xvyymjxdors6kqya@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Seq: 48986 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: 2021-06-02 13:34:57 +0000, Daniel Shahaf: [...] > Haven't read the whole thread, so apologies if I'm missing something, but: > > Please let's not invent a reserved word that uses different variable > expansion rules. The sequence «hash[$key]» should mean the same thing > everywhere. That's the problem here. It's already different in hash[$key]=1 typeset hash[$key]=1 # same as in assignment in recent versions # of zsh where here typeset is a keyword (( hash[$key] = 1 )) unset hash[$key] # globbing performed. read hash[$key] $dryrun typeset hash[$key]=1 # here typeset not recognised as # keyword $dryrun typeset 'hash[$key]=1' read 'hash[$key]' let 'hash[$key] = 1' # yes, it works despite the single quotes # and is actually safe it seems unset 'hash[$key]' # unsets the element of key $key (literally) (see also https://unix.stackexchange.com/questions/627474/how-to-use-associative-arrays-safely-inside-arithmetic-expressions/627475#627475) Parsing rules are different because we are in different contexts. For unset hash[$key] or unset hash[(e)*] to treat those as associative array lvalue, and not globs, it would need to be a reserved word, like typeset above. But, yes I agree it's all very messy. > Instead, we could have a builtin that takes two separate > arguments, as in «foo hash $key» (and «foo hash ''» to unset the element > whose key is the empty string). > > Makes sense? [...] I suggested: unset -k "$key" hash for that. -- Stephane