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=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 E4A9E24715 for ; Tue, 5 Mar 2024 19:43:14 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709664194; b=KQ5mMopx4S0kU2cefkPJ0vKMxiiUI2yE5N+fWlISYB0EimcPvDNkvSR+WX7pxoCTUc89/vS6mU JYGNX24t+tpXyru6wqaIRmFrwfCOIesGUOkJEvVJ6nea5IZDmKuzLrqVkeLMO5PiGCO5+YjS3A FcEKJ+9FJdBmr9LS8hUuWlP5O45Vu36CXbpj1JcQD518fHvFCl8wWk4HX/G4nbAVLnPcuXsnPL 0tmNEVd6P7dT+reRJMf1GkMTzfwC6md5I8Onek5YhNnkYL+libAbWpfHP//H2pNP5kOQhxiKQ1 2xRPVllSwYmKh1XZ8KV7BjfhdF9fQYVbkoypiofVDAW4DA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f47.google.com) smtp.remote-ip=209.85.218.47; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1709664194; bh=LJKx1vBhOfT25SyPprWqoSat3MT8/JT4iheb/jp9C3I=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=CY9D/O/fdlt9LZZdak/vVf4Cy9dh6VfeoAXnHU5YKecS+oa5R49Cz1eg7RB/Mqc8GuYYrVF3Db pgYvS1cCYdD4b7aq7l8L6t3VS/jAs10UYy5R9X6MBFzfUttRcwR60hSwh+j2dFQDEOjizpIY1R 3z+Y79Ur1S8V1sp7VNXQe62dYOCtUDHlv7SqTofgq4hhcArgx1RfSNMLeeEu2nrb0ramsl5EZk Fr9aFl6/jz+P9MIVvu4+pMCrIGzYqe2ra0624+IgwTc0RvwKOqBkkA34EA3Mm7rA5YGB5uKAE7 8UNSl5k7qjk8xpkgnNSCJsTGu6Fdzr3IzJ4EGxxBalQcLw==; 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:Content-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=gNrOgyvsM0Zfc4tYhrk98sTHd5OYwPStIKQ5Pphvs1I=; b=LyWYXmQKqpPVEzi2iHzEPmCIBI tQx/j309hy5olX4QvKNor4F1uI27RO2pE7WHCKdcqmBtqIT/yENkLyecyK4/D+ZCG3P6MR7Ky8rbd oacgPkP0Wts32pmeZXOn43pay7YxKYJmqujRQcF2S5TSUZKq8r/vPoC8LVqybdswHIRqQPVzMwVBr X2C+Uxm2fM2t52a8Xpy1wNJusH3c/9XVqYR3Uz3wql5fqlskP5maw3B3F3wNNJld8hEtyqupPR2z1 KbhiSKEObUJw+0Rqnl8Oh0D/sWq7odhiI8TV6Y+e+gvXbO6NVZtnBOG+BJd7yWjKG0ElU/Xj165if xb5S3s1w==; Received: by zero.zsh.org with local id 1rhZkv-000L0u-9v; Tue, 05 Mar 2024 18:43:13 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f47.google.com) smtp.remote-ip=209.85.218.47; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f47.google.com ([209.85.218.47]:44489) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rhZkF-000Keq-Fi; Tue, 05 Mar 2024 18:42:33 +0000 Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a44f2d894b7so427660566b.1 for ; Tue, 05 Mar 2024 10:42:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1709664150; x=1710268950; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gNrOgyvsM0Zfc4tYhrk98sTHd5OYwPStIKQ5Pphvs1I=; b=qtTdhuupaRp42KxQu6nG+T7NGcnZQsuucqfNjBH9bxAwBcoM6IgAnKcGX0Sj75Fn3G UiWEAHo4ilGhE21K2Tb6K6hHEEX47R9Jwb9fABChBdRuXunSDE4AjO5BwxJdq0KzH5L6 tvoz17Xyk2Cihai/N9hbxpnuh7ULcj0/r3s41h5CnllMhejLQRLtJSge2wHv3cJMMl91 gL4jpIfrffdBsPaHWYWhCFIihgEDND4uYFmim4DchSN3jj+vZpkMJZD8ZFTQMfs8OSpc njtSUQ3JjzQLnIhgofTkvBuEtL3KGe6UTBBmQDK9aOLNiUuT1VXXOoltDvZnsu3sGywr KdEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709664150; x=1710268950; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gNrOgyvsM0Zfc4tYhrk98sTHd5OYwPStIKQ5Pphvs1I=; b=EKTopFECdK2V+mGXuFFwfx85ljBaqdPnLysfAniQIi9zR0oI82aA19J9qRUYr2+kmm zuyo391v+Ke89gscqPlXNJyTy5oDV4ivLCQdVcSHZmxA5S09t9Z5TxoyQjPfnEDxs2Z7 IOilXZdK9sO1v64++gxG61fgGgRFfRmW99wWREz5svy0pvKLBOZtRLp1koeVcAiSHnSR x8NvKlq8XWhWz5DK2iVWyqWlEDfWQxRwYm/8GeQ/LfldY6rP1u5E2U+hemM1gSVHFB1c 7rEF04UDY4C5gR/Y/A9kOSjXZn6d9cBTNyDQtz1bPwV+2Lqj5CpGY2GXytKDFE+iPoHt 7B9g== X-Forwarded-Encrypted: i=1; AJvYcCWdF6SS93gQ+pwpfxP2dRtW34lN8/x6Xnd0teb+uiPBuDy/zYjn/sa9V1PZQG2EhLGQ2yQGLek1TCFIpeH3zg1XZBD/ X-Gm-Message-State: AOJu0YwmJn32/e/yoAvZrhEZHBvvmgMKjSMZbYQcrb8KeaJv+9VP6dbq nMWZfVxVol8Ofl4EtdhTu+57dcAwcPT6Q25PonoGYB5GHvdSjJIx6UYBOj3etyAnq0jzIAo9J7Y knWigxlM7UL8DcFu197WDXQFT8/2Uppivq1nOy2ovuIH1pxRY7A== X-Google-Smtp-Source: AGHT+IHsxxvKuvtHUpHPLn29qtEmXoHIZE3LLKVjE/MDC0Vun9x2utWNzDlStcWN/ZL+TkYN2GjtT6+a8KrJBbu6OuQ= X-Received: by 2002:a17:906:3442:b0:a44:3ec9:1fd3 with SMTP id d2-20020a170906344200b00a443ec91fd3mr7383056ejb.30.1709664150333; Tue, 05 Mar 2024 10:42:30 -0800 (PST) MIME-Version: 1.0 References: <20240304062914.kn6wquvgog3lefom@chazelas.org> <20240304193409.lv725ah6eifiazzx@chazelas.org> <20240305081859.r3qwiyduk2wgkdby@chazelas.org> In-Reply-To: <20240305081859.r3qwiyduk2wgkdby@chazelas.org> From: Bart Schaefer Date: Tue, 5 Mar 2024 10:42:18 -0800 Message-ID: Subject: Re: [PATCH] Fix crash on unset-through-nameref To: Bart Schaefer , Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52686 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: On Tue, Mar 5, 2024 at 12:19=E2=80=AFAM Stephane Chazelas wrote: > > 2024-03-04 15:18:06 -0800, Bart Schaefer: > > On Mon, Mar 4, 2024 at 11:34=E2=80=AFAM 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 |=3D PM_EXPORTED; */ > I hate to say this but it seems to me that if this kind of issue > is not fixable, then it would likely be preferable (from a > consistency PoV at least) to go for bash/mksh dumber approaches > where namerefs are just plain scalar variables containing the > name of another variable (or other lvalue) and having the target > variable resolved any time the nameref is assigned/referenced That is in fact exactly how it works, with the addition now that -u makes it skip upward one scope before resolving. > (see also > https://unix.stackexchange.com/questions/640687/prevent-command-substitut= ion-from-running-when-declaring-a-variable/640695#640695 > where namerefs are abused to have a variable with a dynamic > value). Although I wasn't aware of that discussion, I had already thought of that: When RNAME includes an array subscript, the subscript expression is interpreted at the time ${PNAME} is expanded. Any form of subscript is allowed, including those that select individual elements, substrings of scalar strings, or multiple elements as with array slices or the '(i)', '(I)', '(r)', '(R)' and '(w)' subscript flags. However, the subscript is evaluated with the NO_EXEC option in effect, so command substitution and other similar constructs produce no output, although are not syntactically excluded.