summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2024-03-01 15:43:50 -0800
committerBart Schaefer <schaefer@zsh.org>2024-03-01 15:43:50 -0800
commit13f73d84d3a69085df148e7cfe03ed6448a1238b (patch)
tree253e194e86dfe61dc2b1895ceb24346e10a76b0b
parent85172998f499cb789570714ffdd43f1ca3b53e58 (diff)
downloadzsh-13f73d84d3a69085df148e7cfe03ed6448a1238b.tar.gz
zsh-13f73d84d3a69085df148e7cfe03ed6448a1238b.zip
52645: unset through a nameref keep up-scope parameters declared unset
Othewise unset of a reference to a global wipes out all parameters of the same name.
-rw-r--r--ChangeLog5
-rw-r--r--Src/builtin.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9ab0218c9..31e90dfd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-03-01 Bart Schaefer <schaefer@zsh.org>
+
+ * 52645: Src/builtin.c: unset through a nameref keep up-scope
+ parameters declared, and not wipe out the entire parameter stack
+
2024-02-28 Bart Schaefer <schaefer@zsh.org>
* 52619 (plus tests): Src/params.c, Test/A06assign.ztst: there
diff --git a/Src/builtin.c b/Src/builtin.c
index 44dfed651..83144677b 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3932,8 +3932,14 @@ bin_unset(char *name, char **argv, Options ops, int func)
}
} else {
if (!OPT_ISSET(ops,'n')) {
+ int ref = (pm->node.flags & PM_NAMEREF);
if (!(pm = (Param)resolve_nameref(pm, NULL)))
continue;
+ if (ref && pm->level < locallevel) {
+ /* Just mark unset, do not remove from table */
+ pm->node.flags |= PM_DECLARED|PM_UNSET;
+ continue;
+ }
}
if (unsetparam_pm(pm, 0, 1))
returnval = 1;