From 13f73d84d3a69085df148e7cfe03ed6448a1238b Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Fri, 1 Mar 2024 15:43:50 -0800 Subject: 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. --- Src/builtin.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Src') 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; -- cgit 1.4.1