Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Fix crash on unset-through-nameref
- X-seq: zsh-workers 52689
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] Fix crash on unset-through-nameref
- Date: Tue, 5 Mar 2024 19:38:40 +0000
- Archived-at: <https://zsh.org/workers/52689>
- In-reply-to: <CAH+w=7bJsoJcDz0aNr9G11On4a_fssw3QJHTrtzQnT75n8A-Hw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- References: <CAH+w=7ayqWoufueuaHiCzjmzgHtv6VV0m7mEXoHn5nGq4pNOzg@mail.gmail.com> <20240304062914.kn6wquvgog3lefom@chazelas.org> <CAH+w=7b9dcQ4f=71rFZSWBVEJ4bzj7NxzD2-zoj2TkpaCkaCjw@mail.gmail.com> <20240304193409.lv725ah6eifiazzx@chazelas.org> <CAH+w=7ZiTe_hPoBRtHBsRHRvifkiaCJPOCzRSpz0H=XHV8rNbw@mail.gmail.com> <20240305081859.r3qwiyduk2wgkdby@chazelas.org> <CAH+w=7bJsoJcDz0aNr9G11On4a_fssw3QJHTrtzQnT75n8A-Hw@mail.gmail.com>
2024-03-05 10:42:18 -0800, Bart Schaefer:
[...]
> > 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.
[...]
Well, not in the:
$ ./Src/zsh -c 'f() { typeset -n ref=var; local var=1; echo $ref; }; var=0; f'
0
Which IMO is better than
$ bash -c 'f() { typeset -n ref=var; local var=1; echo $ref; }; var=0; f'
1
$ mksh -c 'f() { typeset -n ref=var; local var=1; echo $ref; }; var=0; f'
1
But is IMO somewhat inconsistent with:
$ ./Src/zsh -c 'f() { nameref ref=var; local var=1; echo $ref; }; f'
1
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author