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

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



On Mon, Mar 4, 2024 at 11:34 AM Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
>
> 2024-03-04 00:39:30 -0800, Bart Schaefer:
> >
> > Try removing this line from the patch:
> >
> > +    pm->node.flags |= PM_DECLARED;
>
> $ ./Src/zsh -c 'myunset() { typeset -n v=$1; unset v; }; export x=1; myunset x; typeset -p x; x=2; typeset -p x'
> export x=2
>
> 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.

You'll note it also didn't say
  typeset: no such variable: x

... because there is no provision in the parameter implementation for
a global to occupy a table slot and yet to appear not to exist.

This is one of the reasons your desire for "create it an as unset at
the time a nameref mentions it" has inherent problems.




Messages sorted by: Reverse Date, Date, Thread, Author