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 10425 invoked from network); 14 Jun 2021 07:20:03 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Jun 2021 07:20:03 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1623655203; b=IdWfBeyURJuiEBGKBhk/MFxjKmH6a2T/tLflsJKiYhMXQO0D4783n9oNbquByBbO9gyPD8bkSg NtivFJLWsHQcEztbSazTJJbL3HobxOGHcOmlkHFOxCEOiJHkKC4tHdPN1CnbWDfCamXxc73D6k Nm5DZ1EVEu93SaqzocweDeDb5Rjwc9/I2yFiQLRfEj8F5Eg3H8KlmhGh3eCSUe6SXuWzU3gSpQ sX/qGHyJDPdtHEiE/y0EBSvnhF+k1ok9KwXGR2VVop7DVsD5ppeEKQEhCoUZPKvkq72JsCxBXc nCGKeOiflLJM1YopbG484F6eXXYOUkhiiOaLoxr8I3/jbQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; 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=1623655203; bh=fWcV/wepE/AjL9CBgGbV4N/9Jc64xtHsXPqJ1wzFv7M=; 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=BaU0j1iQT5hoPjSom4Y3DoPMlADhqJl8MXTCdo4vZmze4vW9VkjgRsob8q8g+Zf+H83Bq3SwBn zUs3oTfsZEZC+ZySynbgXAFBKfIVOl7InnQtfwd3hL4+IQ45750fxW0dqmWLiC0eJ+ANqHboXY CceUJrfkGMIhnclvuqIHeQfHT5uJNh+QEfbyBgKiw4ayND8EzD8leUfYyp02fCaifccgKCWVcL 1eaLRLd8Zx2/k4PYnZ8XdtyzVaYtyGDW+pMc+FSEv8TC8zFQOiVByhVNRpEP7dQ68aq+VrrqK5 mX4VBNjyJ69V+Q+y99C1NYnwspCau5zjauAXEzGlK0T+Pw==; 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=SwkZkOUuUc/tIM+F4F4/w8QsKedkk1M/IiOjHiivZGQ=; b=o5gnC4u1L/52Hcnbd8UkDwm4NC YGCte8bY61//5A5OheTxiJ8eU+m1y3dEJlglLWDPJlxh/xNC6ff+jTxbmJnSwI1ErcLXTRQvWXUjf U3Ay6mDYBN1SLzE3dm0CSpOqrf2tuxmL6s6sspY2glVV5U3rS5JNIYM1pjfxkmayf94N51pTjFC4j nbFddO+lYaYadKP7da26RGYUYoMJ1uvRTJNUyCZCeyILA+IRMUqkH+qj/6Rv5nF06pXsRQ/JihxCc ocD7jJItiZ03FAjnjU+TvJGlQo8P41LTGpUSc89nlyKqdl9gkXgmMYgDiRfs+3vrSUOOxg14Pj0oq UH7yumJQ==; Received: from authenticated user by zero.zsh.org with local id 1lsgt7-00089f-75; Mon, 14 Jun 2021 07:20:01 +0000 Authentication-Results: zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; dmarc=none header.from=chazelas.org; arc=none Received: from relay3-d.mail.gandi.net ([217.70.183.195]:52969) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lsgso-0007qZ-Ta; Mon, 14 Jun 2021 07:19:43 +0000 Received: (Authenticated sender: stephane@chazelas.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id D148060008; Mon, 14 Jun 2021 07:19:41 +0000 (UTC) Date: Mon, 14 Jun 2021 08:19:40 +0100 From: Stephane Chazelas To: Bart Schaefer Cc: Peter Stephenson , Zsh hackers list Subject: Re: [PATCH (not final)] (take three?) unset "array[$anything]" Message-ID: <20210614071940.xugzcv63habfegjo@chazelas.org> Mail-Followup-To: Bart Schaefer , Peter Stephenson , Zsh hackers list References: <1629605749.599911.1622710481163@mail2.virginmedia.com> <20210603131347.i7bv7ao7j3hk3a2e@chazelas.org> <1005646394.611235.1622731315969@mail2.virginmedia.com> <6329352197c60d24bd605f329f8e613af63f76df.camel@ntlworld.com> <6030724c6ec1e5ebdd51f5c85889b72faa6dd93a.camel@ntlworld.com> <08ab86ab56067a281a322cfe76eddb78de3bb368.camel@ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 49070 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-13 14:44:03 -0700, Bart Schaefer: > On Sun, Jun 13, 2021 at 12:50 PM Peter Stephenson > wrote: > > > > Yes, in fact those are the same thoughts that flitted through my mind. > > One other idea ... NO_UNSET could warn if you unset something that's > not set, as well as when you $deref something that's not set. That > would at least blat at you if your hash key was misinterpreted. Note that nounset is a POSIX option. And for the unset special utility: "Unsetting a variable or function that was not previously set shall not be considered an error and does not cause the shell to abort." POSIX has no jurisdiction over arrays/hashes, but that does mean we can't have unset fail on unset variables when in sh emulation at least. A shell that would fail upon: unset var When var was not previously set would not be compliant. A script that would do unset "var[foo]" Would not be a POSIX script as var[foo] is not a valid variable name, so implementations are free to do whatever they want for them. But if zsh returned failure for when var[foo] is not set and not in unset var, that would make it quite inconsistent. Changing the behaviour would likely break some scripts that use errexit as well. -- Stephane