From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id DC3F8253BD for ; Tue, 5 Mar 2024 23:12:39 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709676759; b=TzIIZgBMAhjrv4gqyV+jdNrxOrbVKeOm31ElAcDWqP1EbfgB+T65/v1tf3QAMLi4RmBExSsDZR n/M2VugkdiOXS6o89uVrJ3yafy+gJREvwArtAcGKPETnFdKHgGBwvdv+4JLS5vWZ6mbH6z1zYd /vC/IFgNl+443uv7/cD80FIElixG8Cu8ONzc+PCHiUM4/TV0lwhJHgOXgPwEjhS67R0avZg+gR +d5RDGB2K/ZSX3GRsG2MxXGgHaZ+kjq8Vup0MiDuNmy3ndbpCDGggD1jfi8CeTONG9jZ2REES4 PxCXUmGQDx+o049/aqara63xlRv0gzgsFaHk+j58GXFXVA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mslow1.mail.gandi.net) smtp.remote-ip=217.70.178.240; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1709676759; bh=k0NCmzwbWyeZsyzWGP2hTQWL4dmjBpDrqZ3eMkTeFVA=; 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=kxZHTNnQuq3pE7BElThNXOhArplVm67LNS4xTU5iX5+370qt6OZZBwFTJQKsR2vn201RI1uc0r Unv55NiGg3uqiKv6XwZpGg0NCh9+csDXpvU0j7dOxRj8OfbPkP+mRvIGWT/d2PLX/28YWbpHqh 2PS10m6SqdpvLo7HHG7ZhA04Ky6z0SBCvidOSvjVKmgZjevwWlyk3M2v5jGAaAzA78qvB3fqg9 Zn22IOkJTuCY7fCpaKOICCcpejBEUFvIbTHPFBc5QAIU14rcktAAwrynp/2i4seHqbOCM/u/qM A09HkjC9Iy7R1nu02MADs+Su5gvAh44RZvrUPTzPbj4Wxg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; 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=liRKAxXv28zo/Tkxdw/kvAxwV6T53at62WtcyZSqQLw=; b=ISuCD+oG9qUm0NXfq3yNW7/G2p 7n0M0qA1LWWw7ctQyPorDzH4AWymYMhP6Py9/4qWzkhsOa0gPi2XoS0d6sJwWvmNtMkbgI7VRhh6g ft4h9QOgY4qQCPAu+nAu/5ViThFOQJq1dNKMS3saxsvlQSywhQGEVuiDX4D4j1lyKmG7bWFl/yJoE uDWX84QBzJlf29d8UOMEjPEBkeClg8KdW4ECYAQlD7BQbWOI6DY4BesltFlCR+aFEWCeiGyr9Lxoz 5WEls+fkp8BJ+vmet8vxDZPQ4/VtcqMCUc5p1NkrF+coGrcA1uUF3fiaWdRhWrWnid5DjR8lKtRyA KoMfFh0w==; Received: by zero.zsh.org with local id 1rhd1b-0002jl-3U; Tue, 05 Mar 2024 22:12:39 +0000 Authentication-Results: zsh.org; iprev=pass (mslow1.mail.gandi.net) smtp.remote-ip=217.70.178.240; dmarc=none header.from=chazelas.org; arc=none Received: from mslow1.mail.gandi.net ([217.70.178.240]:39001) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1rhd1P-0002Po-PB; Tue, 05 Mar 2024 22:12:28 +0000 Received: from relay5-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::225]) by mslow1.mail.gandi.net (Postfix) with ESMTP id AC4C6C1887 for ; Tue, 5 Mar 2024 19:49:19 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0C3DC1C0002; Tue, 5 Mar 2024 19:48:57 +0000 (UTC) Date: Tue, 5 Mar 2024 19:48:57 +0000 From: Stephane Chazelas To: Bart Schaefer Cc: Zsh hackers list Subject: unset, POSIX and the export attribute (Was: [PATCH] Fix crash on unset-through-nameref) Message-ID: <20240305194857.6e7ublhkdo276r3k@chazelas.org> Mail-Followup-To: Bart Schaefer , Zsh hackers list References: <20240304062914.kn6wquvgog3lefom@chazelas.org> <20240304193409.lv725ah6eifiazzx@chazelas.org> <20240305081859.r3qwiyduk2wgkdby@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-GND-Sasl: stephane@chazelas.org X-Seq: 52688 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: 2024-03-05 10:42:18 -0800, Bart Schaefer: > On Tue, Mar 5, 2024 at 12:19 AM Stephane Chazelas wrote: > > > > 2024-03-04 15:18:06 -0800, Bart Schaefer: > > > On Mon, Mar 4, 2024 at 11:34 AM Stephane Chazelas wrote: > > > > > > > > It still retained its export attribute. > > > > > > This gets messy because POSIX says that's exactly what's supposed to > > > happen when unsetting an export, even though in native zsh it normally > > > doesn't work that way. > > > > No, I think you're confusing with: > > > > export foo > > I'm referring to comments in the C code, e.g.: > > * POSIXBUILTINS horror: we need to retain the 'readonly' or 'export' > * flags of an unset parameter. > [...] > if (isset(POSIXBUILTINS)) { > [...] > /* This is handled by createparam(): > if (usepm && (pm->node.flags & PM_EXPORTED) && !(off & PM_EXPORTED)) > on |= PM_EXPORTED; > */ [...] But AFAICT, that's about the "export var" when var is not previously set. You can't unset a readonly variable anyway. zsh retaining the export attribute of a variable upon unset would make it non-compliant. POSIX is not ambiguous on that. See https//pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html#unset "unset - unset values and attributes of variables and functions" "Read-only variables cannot be unset." -- Stephane