Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Fix (mainly nameref) issues in builtin "unset"
- X-seq: zsh-workers 54720
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] Fix (mainly nameref) issues in builtin "unset"
- Date: Mon, 8 Jun 2026 17:54:57 -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-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2TGSQhsH482jxBhbDD5YwR+jS5w8Cflg7lUknIs0T3U=; fh=RngAOd9wlRc8Glv1v2GOfDUnq2FsyrczungEY8JNfXY=; b=LJ2/qh98Q0TelW8PY4YnJ7ByziV10oEVMFNmc/n1vbb947j9Jzkw8018aYZf1zNCfQ 3X8dv+VOO1MaD4XPXsdGc6uavJYltaKU6re+FjbzUTwuuBrkp/9yjalT/7anX4qb8NbV q/tkiI5QaHnRHocdmAcv9V5bPbMeYHwWq7+f9Ea5Q60DtjNbnFYHny/77ixQQBWwIkVH G1mmBX80w8dml2D1qS+9wV+AXvkgyRNHLp49akioTOLhH2BUfHjfTHBgcUOaRc6e3mPE wPY8UGYEI+h7JF9q/aGiDYYkBvddU+9Pa7DKZN9pnM5t4B9gxVi/92E8C6zrj0FCW3sR UYWg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1780966509; cv=none; d=google.com; s=arc-20240605; b=NcL2TNAUeWPgvwegmnRd/mw9gOD9xJKVBGBRdg5j1+CbEYqKQ35QPzyndwpUXYGyM/ Y0n0ZTOoYJotgrHfUlE61DAwMOjdQEi9lMXY8gMuoeoAPMBkUFx/L0ffhfv2JjttKKwT Gp/CBjosEHNlk5lDaJMdA23+yvz+OUivjnxtN6ZpeVmqvR0E66HISxIz0too9usT8WUP tMUYcHS4iII3HSpb/VZdDYuvx6LbXANFvhynukx5ypzHd6pTPsfBKOni+M8BwjTQ2dHo yX89X2q7NGGKuCAlIWD1eKcCL/V/zRZwvsWEqcTff+oR3P8YL6hvS6EcAwPTtesdJQyw yTww==
- Archived-at: <https://zsh.org/workers/54720>
- In-reply-to: <CAH+w=7Yyr4TMiJY1aN3CdUxmXH5C--q+WmH_JDMkFstcQYQCHw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchuxyh2qztz9x4CdHZDXrLJ5d-u_p2LRgBmDrZPk-wK92Q@mail.gmail.com> <CAGdYchtvG5np68K7Yf92Avf8J5--WOW8phaWg8ZNYTuqO0mfWw@mail.gmail.com> <CAH+w=7Zxxw7Zxo2NFVLJXy485QZxZu1u+2ema1UY1SPGHaxVgA@mail.gmail.com> <CAH+w=7Yyr4TMiJY1aN3CdUxmXH5C--q+WmH_JDMkFstcQYQCHw@mail.gmail.com>
On Mon, Jun 8, 2026 at 5:48 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Jun 8, 2026 at 4:08 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > Applying this produced rejections in Src/builtin.c. I tried resolving
> > them by hand, but then got a lot of Test/ errors on K01nameref.ztst
> > referencing restricted mode. This patch seems to have put back those
> > tests?
>
> I may have applied the wrong version of this patch. Trying again.
I do seem to have applied the wrong version, but I have different
failures following the more recent patch:
./K01nameref.ztst: starting.
--- /tmp/zsh.ztst.59959/ztst.out 2026-06-08 17:49:48
+++ /tmp/zsh.ztst.59959/ztst.tout 2026-06-08 17:49:48
@@ -1 +1,7 @@
+typeset -g .K01.scalar
+typeset -g -A .K01.assoc
+typeset -g -a .K01.array
+typeset -g -i .K01.integer
+typeset -g -E .K01.double
+typeset -g -F .K01.float
typeset -g -r .K01.readonly=RO
Test ./K01nameref.ztst failed: output differs from expected as shown above for:
typeset -g .K01.scalar='RW'
typeset -gA .K01.assoc=(x y)
typeset -ga .K01.array=(z)
typeset -gi .K01.integer=0
typeset -gE .K01.double=0.0
typeset -gF .K01.float=0.0
typeset -gr .K01.readonly='RO'
typeset -n gref
for gref in ARGC .K01.{scalar,assoc,array,integer,double,float,readonly}
do
{ unset gref } always { TRY_BLOCK_ERROR=0 }
done
typeset -p .K01.{scalar,assoc,array,integer,double,float,readonly}
unset .K01.{scalar,assoc,array,integer,double,float}
Error output:
(eval):11: read-only variable: ARGC
(eval):11: read-only variable: .K01.readonly
Was testing: unset various types via nameref, including a readonly special
./K01nameref.ztst: test failed.
--- /tmp/zsh.ztst.59959/ztst.out 2026-06-08 17:49:48
+++ /tmp/zsh.ztst.59959/ztst.tout 2026-06-08 17:49:48
@@ -8,5 +8,6 @@
typeset -n ref1=var0
typeset -n ref2=ref1
# unset -m ref2
+typeset var0=foo
typeset -n ref1=var0
typeset -n ref2=ref1
Test ./K01nameref.ztst failed: output differs from expected as shown above for:
test-unset() {
typeset var0=foo
typeset -n ref1=var0 ref2=ref1
typeset cmd=(unset $@); echo "#" $cmd; $cmd
typeset -p var0 ref1 ref2
}
test-unset ref1
test-unset ref2
test-unset -m ref1
test-unset -m ref2
unfunction test-unset
Was testing: unsetting references without -n unsets the referred parameters
./K01nameref.ztst: test failed.
--- /tmp/zsh.ztst.59959/ztst.out 2026-06-08 17:49:48
+++ /tmp/zsh.ztst.59959/ztst.tout 2026-06-08 17:49:48
@@ -1,11 +1,8 @@
# unset ref1
-typeset -n ref1
typeset -n ref2=ref1
# unset ref2
-typeset -n ref1
typeset -n ref2=ref1
# unset -m ref1
-typeset -n ref1
typeset -n ref2=ref1
# unset -m ref2
typeset -n ref1
Test ./K01nameref.ztst failed: output differs from expected as shown above for:
test-unset() {
typeset -n ref1 ref2=ref1
typeset cmd=(unset $@); echo "#" $cmd; $cmd
typeset -p ref1 ref2
}
test-unset ref1
test-unset ref2
test-unset -m ref1
test-unset -m ref2
unfunction test-unset
Was testing: unsetting placeholder references or their referents has no effect
./K01nameref.ztst: test failed.
--- /tmp/zsh.ztst.59959/ztst.out 2026-06-08 17:49:48
+++ /tmp/zsh.ztst.59959/ztst.tout 2026-06-08 17:49:48
@@ -1,6 +1,8 @@
# unset refg1 refg2 refl1 refl2
-(anon):typeset:7: no such variable: g1
-(anon):typeset:7: no such variable: g2
+typeset -g g1
+typeset -g g2
+typeset l1
+typeset l2
# unset -m refg1 refg2 refl1 refl2
(anon):typeset:7: no such variable: g1
(anon):typeset:7: no such variable: g2
Test ./K01nameref.ztst failed: output differs from expected as shown above for:
test-unset() {
typeset -n refg1=g1 refl1=l1
() {
typeset -g g1=glb1 g2=glb2
typeset l1=lcl1 l2=lcl2
() {
typeset -n refg2=g2 refl2=l2
typeset cmd=(unset $@ refg1 refg2 refl1 refl2); echo "#" $cmd; $cmd
} $@
typeset -p g1 g2 l1 l2 2>&1
} $@
unset g1 g2
}
test-unset
test-unset -m
unfunction test-unset
Was testing: unsetting references referring to parameters in enclosing
scopes unsets the parameters
./K01nameref.ztst: test failed.
--- /tmp/zsh.ztst.59959/ztst.out 2026-06-08 17:49:48
+++ /tmp/zsh.ztst.59959/ztst.tout 2026-06-08 17:49:48
@@ -3,10 +3,10 @@
typeset g=hide-g
typeset l=hide-l
# outer scope
-test-unset:typeset:12: no such variable: g
+typeset -g g
+typeset l
# unset -m refg refl
# inner scope
-typeset g=hide-g
-typeset l=hide-l
# outer scope
-test-unset:typeset:12: no such variable: g
+typeset -g g=glb
+typeset l=lcl
Test ./K01nameref.ztst failed: output differs from expected as shown above for:
test-unset() {
typeset -g g=glb
typeset l=lcl
typeset -n refg=g refl=l
() {
typeset g=hide-g
typeset l=hide-l
typeset cmd=(unset $@ refg refl); echo "#" $cmd; $cmd
echo "# inner scope"
typeset -p g l 2>&1
} $@
echo "# outer scope"
typeset -p g l 2>&1
unset g
}
test-unset
test-unset -m
unfunction test-unset
Was testing: unsetting references referring to hidden parameters
unsets the hidden parameters
./K01nameref.ztst: test failed.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author