about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index ba9cb03c2..0aae1fcde 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3935,9 +3935,11 @@ bin_unset(char *name, char **argv, Options ops, int func)
 		int ref = (pm->node.flags & PM_NAMEREF);
 		if (!(pm = (Param)resolve_nameref(pm, NULL)))
 		    continue;
-		if (ref && pm->level < locallevel) {
+		if (ref && pm->level < locallevel &&
+		    !(pm->node.flags & PM_READONLY)) {
 		    /* Just mark unset, do not remove from table */
-		    pm->node.flags |= PM_DECLARED|PM_UNSET;
+		    stdunsetfn(pm, 0);
+		    pm->node.flags |= PM_DECLARED;
 		    continue;
 		}
 	    }