From: Stephane Chazelas <stephane@chazelas.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] Fix crash on unset-through-nameref
Date: Mon, 4 Mar 2024 06:29:14 +0000 [thread overview]
Message-ID: <20240304062914.kn6wquvgog3lefom@chazelas.org> (raw)
In-Reply-To: <CAH+w=7ayqWoufueuaHiCzjmzgHtv6VV0m7mEXoHn5nGq4pNOzg@mail.gmail.com>
2024-03-03 21:37:34 -0800, Bart Schaefer:
> On Sun, Mar 3, 2024 at 2:58 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
> >
> > On Sun, Mar 3, 2024 at 12:27 PM Stephane Chazelas <stephane@chazelas.org> wrote:
> > >
> > > It segfaults with zsh -x though
> >
> > I'll have a look at that later, thanks.
>
> Variation of the same problem reported by Jun T. when unsetting the
> array part of a tied pair.
[...]
Thanks. That seems to fix it.
There's however a behaviour I can't explain:
$ ./Src/zsh -c 'f() { typeset -n v=$1; unset v; typeset -p w; v=(); }; w=1; f w; typeset -p w'
typeset -g w
typeset -a w=( )
$ ./Src/zsh -c 'f() { typeset -n v=$1; unset v; typeset -p w; v=(); }; v=1; w=1; f w; typeset -p w'
typeset -g w
f: w: attempt to assign array value to non-array
The behaviour of that v=() seems to be influenced by the fact
that v was declared as scalar in the global scope.
See also:
$ ./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
export x=2
That shows an unset through a nameref in a different scope
doesn't do a full unset: the variable remains declared and
retains its attributes (also evidenced by that "typeset -p w").
--
Stephane
next prev parent reply other threads:[~2024-03-04 6:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 5:37 Bart Schaefer
2024-03-04 6:29 ` Stephane Chazelas [this message]
2024-03-04 8:39 ` Bart Schaefer
2024-03-04 19:34 ` Stephane Chazelas
2024-03-04 19:36 ` Stephane Chazelas
2024-03-04 23:50 ` Bart Schaefer
2024-03-05 8:36 ` Stephane Chazelas
2024-03-04 23:18 ` Bart Schaefer
2024-03-05 8:18 ` Stephane Chazelas
2024-03-05 18:42 ` Bart Schaefer
2024-03-05 19:38 ` Stephane Chazelas
2024-03-05 23:16 ` Bart Schaefer
2024-03-06 18:21 ` Stephane Chazelas
2024-03-06 19:17 ` Bart Schaefer
2024-03-06 19:37 ` Bart Schaefer
2024-03-05 19:48 ` unset, POSIX and the export attribute (Was: [PATCH] Fix crash on unset-through-nameref) Stephane Chazelas
2024-03-05 19:51 ` [PATCH] Fix crash on unset-through-nameref Stephane Chazelas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240304062914.kn6wquvgog3lefom@chazelas.org \
--to=stephane@chazelas.org \
--cc=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).