Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [Language Design] How should references to localized special parameters behave?
- X-seq: zsh-workers 55078
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [Language Design] How should references to localized special parameters behave?
- Date: Sun, 9 Aug 2026 17:55:04 -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=O3yeH54JZNAEqftWlPUSGmafRlntFmndpWgs8IZRQJk=; fh=RngAOd9wlRc8Glv1v2GOfDUnq2FsyrczungEY8JNfXY=; b=fpQFYWx00j7ED/vFiHtPpysVacFMoJ2clLnO95hCGzguPtONdfv62sDi5uuUX2V/K+ 5UXTse4PcFHSGut4e71J4nj9VdELTrVelr53PN4FOP41aYRmLn4GXFlva6FS08DCKfHi WZ/n3ihUfAoWb8LEvEyklkQlUyTAx+tnDIJYrPV6SqEAHK5+2TCeRwj9+xI/dHsnup+X 8QVI+vHzskQgA6nNm67yO1PFuVqvcxet7R8/emYomjdUo1h5kZpjWpqzKAQBo3G9DQDn KlIBCJ/R7TgrkJJSEHkH4+PErq5FjFrfAlskhzFgHQX/w3akYPg4kqapBwV5Vhrl2ZV8 eCLQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1786323315; cv=none; d=google.com; s=arc-20260327; b=REFkvo6n+Ako5Rdte/PqZJ3qGIOjOt39YaWo6Cei4r1qilDmHT/l6BHi83A7XjaMi2 leQQ5/LltDsgqWI1KJAAa0G7qA/T/FzyZ92dO3kjJsHyftOYRkV35cf2g9MqkqgGHJ7p zzqzZeRg1WhukHJWH/eGNLwBGgANXZoLyOlEk+7uwx/7vnfZ8Slo/AHuJVjf2ihqA1a0 3tOAFHxfju0HNP3aEIL6ZvVwpb7Ee8WpmK5dT9YS8fTZP4dNNqDeg81qCg3ZhDE0U8Yk ODa2mao/0M7BAYtw8DqTfkLLonsBSiFVlfvPGtvHRX8WCkmt0/yKhzw3RLdyDUPr9/mS JfLA==
- Archived-at: <https://zsh.org/workers/55078>
- In-reply-to: <CAGdYchvbQ33OPjoQ4c-yZ3SscmTOpSk=u7m2zFyOkwgOazxFbg@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchvbQ33OPjoQ4c-yZ3SscmTOpSk=u7m2zFyOkwgOazxFbg@mail.gmail.com>
On Tue, Aug 4, 2026 at 12:42 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> typeset -n home=HOME
> HOME=/bin; cd; pwd
> function fn {
> typeset HOME=/usr; cd; pwd
> home=/var; cd; pwd
> }
> fn; cd; pwd
>
> In particular, what should the effect of the assignment "home=/var" be? Currently, it triggers a segmentation fault.
I think the easiest way out of this is for that assignment to be an error.
> The current implementation of "typeset HOME=/usr" moves the enclosing parameter into the current scope (i.e., assigns "locallocal" to "pm->level" where "pm" is the enclosing parameter's "Param" instance) and creates a pseudo parameter in the enclosing scope that stores the state of the enclosing parameter prior to the "typeset" (i.e., creates a "Param" instance that duplicates most of the fields of the enclosing parameter's "Param" instance). When the local scope is exited, the enclosing parameter is moved back to its original scope and its state is restored to its state prior to the "typeset" thanks to the values stored in the pseudo parameter, which is then discarded.
>
[...]
>
> Wdyt? Which way should Zsh adopt? Or do you see an alternative way?
What if builtin.c typeset_single() marked the pseudo parameter as
read-only and params.c scanendscope() undid that when restoring? (Or
an equivalent.)
Requires a little care to avoid removing PM_READONLY from a special
that is expected to carry it, but it sidesteps the whole issue. The
home=/var assignment would be an error before it became a segmentation
fault.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author