summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/var.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/var.c b/src/var.c
index de1a5f5..fc6d367 100644
--- a/src/var.c
+++ b/src/var.c
@@ -543,7 +543,8 @@ poplocalvars(void)
 			memcpy(optlist, lvp->text, sizeof(optlist));
 			ckfree(lvp->text);
 			optschanged();
-		} else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
+		} else if (lvp->flags == VUNSET) {
+			vp->flags &= ~(VSTRFIXED|VREADONLY);
 			unsetvar(vp->text);
 		} else {
 			if (vp->func)
@@ -627,8 +628,6 @@ unsetvar(const char *s)
 		retval = 1;
 		if (flags & VREADONLY)
 			goto out;
-		if (flags & VUNSET)
-			goto ok;
 		if ((flags & VSTRFIXED) == 0) {
 			INTOFF;
 			if ((flags & (VTEXTFIXED|VSTACK)) == 0)
@@ -636,11 +635,10 @@ unsetvar(const char *s)
 			*vpp = vp->next;
 			ckfree(vp);
 			INTON;
-		} else {
+		} else if (!(flags & VUNSET)) {
 			setvar(s, 0, 0);
 			vp->flags &= ~VEXPORT;
 		}
-ok:
 		retval = 0;
 	}