Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Should VAR[n]=val cmd export VAR?
- X-seq: zsh-workers 54955
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Should VAR[n]=val cmd export VAR?
- Date: Sat, 11 Jul 2026 16:07:32 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PaLBqnTy7VQehMLTIBl8POmljVujJeiruVUzTAIczDE=; fh=RngAOd9wlRc8Glv1v2GOfDUnq2FsyrczungEY8JNfXY=; b=qWkpZe1EKB/AE9vdLUmngHg937qYaSvAl94y3oUml3fRqNtJPFyaedH9U9DWq2ZATW Khgv2irN++XdKWT52yAzjmS6NGzqChAatiMktDI5yDMSmy4PgOxSm+MXw3dMK3ZifCn3 JwxtiRW6Ymc7UMufEOzvvmMhs2ca1xnljfF73hUcU6zR2zN64LP7kfajxMk4b4pY5KMD qJnSdI5uSIk6hUeEgfNPyPdN5lW36nZraoIgheZMvWVnuMUrIZHoT1L0MObSo6B2qtIl 5gtb+cMZ8u0ZOfqMMW5IwEo2UkUOomRgFCCVaJzProcOEQMJ6VKKr+aLFDTRvdduohe0 Ymvg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1783811264; cv=none; d=google.com; s=arc-20260327; b=F1GakiiE4+B7zE79wl+0VyinV6itTZp6GH3HuFTBubL/Fcua+0Grdg0IsGkqALupri zizu6jRnMHkHBNec52ilxtmqYiBXVTY5ZMwddi4hBkWpdW6TFcVfQAerqnvRqg+nDWsm ZOXI3R/XIYJgyqkcYpC4zJY6f/9bNyiK+5+AXIxLDUbQQHvkRNhhls2H/lGCRT1hwasF aQpvC1PZZZKX4vlEuEGMvh/PkpGxro8tJ+TtG2CHzmPTQkUYDvWIw+BxUecdLLHPipZp 6KnoHT8b36MGH5OiLknYu0OEkpPD4xtlQAhgYS8TbDyL9mu/HT72x8TrSltlyrD1QAs+ BoFA==
- Archived-at: <https://zsh.org/workers/54955>
- In-reply-to: <CAGdYchv1GDdh8rKaARs+Lw_zRLrSRc8NTpJ+OS=f2dRwkvM87g@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchv1GDdh8rKaARs+Lw_zRLrSRc8NTpJ+OS=f2dRwkvM87g@mail.gmail.com>
On Fri, Jul 10, 2026 at 8:37 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> This discrepancy looks strange to me. I expected that "VAR[n]=val cmd" would export VAR. I find the lack of export even stranger given that "VAR[n]=val" exports VAR when ALL_EXPORT is enabled.
>
> Wdyt?
I think the current behavior falls out because ...
1. You can't export arrays (neither simple nor associative).
2. You can't export individual array elements, and subscripting "looks
like" an array element.
3. ALL_EXPORT is implemented in a completely separate part of the
flow, that isn't paying attention to *how* the variable got its value.
That is, conceptually ALL_EXPORT just causes the "is exported" flag to
be set, the actual export isn't simultaneous with the assignment.
> Could we change inline assignments to also export parameters with a subscript?
The question to my thinking is whether "X=Y cmd" is defined as
exporting an "object" X associated with its current value (which is
what ALL_EXPORT definitely means), or defined as inserting the string
"X=Y" into the environment of "cmd". If the latter, exporting VAR[n]
is impossible, you can't export part of an object, an environment
containing "VAR[n]=VAL" is not a valid construct.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author