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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30758 invoked from network); 5 Jun 2021 17:06:06 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 Jun 2021 17:06:06 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1622912766; b=NSrtCeO5JgYbmyVS472ZUuqVeguBg5GRlJyXUdInqc1ssp7vaXv7YT9DgdGDOCNRknk7JVN0yu EXDUr1y5sOAc+mmbxKj85MP7+DOPuSt7psQ3BTpFDKCNxgzCQR0WRrRGNJOPWDOWhD+RtcPmHS h7/+gjYQuhEOD2WxwWfm61HvBKQHYMlIZApjm/iwRSAQJqnVtXgJC93DfDZCke4XIosjC5i3IX T2TdRZdXBg3Ax3ValReBXPH5BGG0dmHyOqBzTEQx8igi1PZlamaHtAvzHGzdEond1uTAnukx55 RVfGkJ1vPQiu57nyRH82LEIvaUFZf1QOssAcyU34RqBx3A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay11.mail.gandi.net) smtp.remote-ip=217.70.178.231; 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=1622912766; bh=d8YvwPVYvrt+/mlcR52uDZ6iilwgKC9ARJhhO92v2hE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=U5aqs2h0RQomK70XSmMWlFy3n5gyJr/yuRwNpRITsFVEmi9aTj67dtCpnq1T2VKUKUIu3aON4c 6H2MJNyjI8cmkwFtYdHSQ2yvZF6TMGOv6wK5ol6qHzUatSFTsTsb4yjpouzUlBVvSQINTMdYsd qOjbD2wmsb397sJ/3iEExS64YlEU6uDz8oH0Ge68HcudJ7Vo0by+FEaTFLE3dwjNSaOQXElj3a 2e55m4DCCbHk/CpIURB9lzGEfgrD1JoWuBd7yDdIuOJtyhkr2iqLVBn7GVzi6ca7a1NzTAVlfq ZMg05MqD94J4yhcthk1AG97mUtMlxDpzWPtHIOPkoKVScw==; 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-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Z2VWv2fU2R9SBlsR/7uw2V/fpmyclKRqfVFV3qGJ02U=; b=qe5EeWdOcj3iPpHWaf5MMSOx1L of2xNrJ+ByF71jpvhmFsX8S0i2B+51h0PHRrIZcXteDSbIi/6jbT9zej10um2I6IYykEWKzToomKR huxPrxcAkIrR4sLKfPNjBuByJjDD7aoEzCxsMjavzzbnctfWZLfKI+xK/oJ6+Aa1lLtteza8wOBy8 3pX21s12Nrxppnfcp+5XYStGF89M/yobpxI0G7HiqaCTgHM+k6dwkeyj0akvEItwkSYLPws8aQO1B n3y9929yu5qXrSLsLEPacM6sK6vVsFq/ElMzzQjWMsZPOYH4BQjBnTUMt0cNV8tl3DLjiZ9iXdC5d frCoQ3FQ==; Received: from authenticated user by zero.zsh.org with local id 1lpZkM-000Hui-8b; Sat, 05 Jun 2021 17:06:06 +0000 Authentication-Results: zsh.org; iprev=pass (relay11.mail.gandi.net) smtp.remote-ip=217.70.178.231; dmarc=none header.from=chazelas.org; arc=none Received: from relay11.mail.gandi.net ([217.70.178.231]:40033) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lpZjp-000Hc4-UR; Sat, 05 Jun 2021 17:05:35 +0000 Received: (Authenticated sender: stephane@chazelas.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id B8540100007; Sat, 5 Jun 2021 17:05:32 +0000 (UTC) Date: Sat, 5 Jun 2021 18:05:31 +0100 From: Stephane Chazelas To: Bart Schaefer Cc: Zsh hackers list Subject: Re: [PATCH (not final)] (take three?) unset "array[$anything]" Message-ID: <20210605170531.af3rj3iurjvvcmdw@chazelas.org> Mail-Followup-To: Bart Schaefer , Zsh hackers list References: <1629605749.599911.1622710481163@mail2.virginmedia.com> <20210603131347.i7bv7ao7j3hk3a2e@chazelas.org> <20210604080200.pnlzjexcuu3oyjcy@chazelas.org> <20210604202116.gnxqqegfnmki2i57@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 49026 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-04 17:20:29 -0700, Bart Schaefer: [...] > > array[1 + 1]=4 > > > > That is pretty annoying. > > That's just shell whitespace rules, though. If you have nobadpattern > set, you get > > zsh: command not found: array[1 > > And if the parser doesn't eventually find ]= then what? Re-parse the > whole thing to word-split it? [...] Note that all other shells that support a[1]=value (ksh, pdksh, bash) do it. In effect that makes them non-POSIX as there's nothing in the spec POSIX that says a[1 + 1]=2 May not run the a[1 with +] and =2 as arguments. I did bring that up a few years ago at: https://www.mail-archive.com/austin-group-l@opengroup.org/msg04563.html (see also https://austingroupbugs.net/view.php?id=1279) There is variation in behaviour between shells if the first word starts with name[ and either a matching ] or matching ] followed by = is not found, and how that matching is done or what kind of quoting are supported inside the [...]. But all in all, even if it may not be pretty when you look closely, that does work fine there as long as you're not trying to fool the parser. In zsh, that would be even less problematic as (at least when not in sh emulation), zsh complains about unmatched [s or ]s (except for [ alone) Even: $ /bin/[ a = a ] zsh: bad pattern: /bin/[ So we wouldn't be breaking anything if we started to accept: hash[foo bar; baz]=x or array[1 + 1]=x We would if we started to accept. hash['x]y'-$'\n']=x like ksh93/bash do though. For literal hash[key]=value assignment, I never remember what needs to be quoted and how. I generally resort to doing var=key; hash[$var]=x or hash+=(key x) which I know are fine. -- Stephane