Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Fix crash on unset-through-nameref



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