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

Re: [PATCH] Fix (mainly nameref) issues in builtin "unset"



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