svn commit: r294593 - in head/bin/sh: . tests/builtins
Jilles Tjoelker
jilles at FreeBSD.org
Fri Jan 22 20:10:10 UTC 2016
Author: jilles
Date: Fri Jan 22 20:10:08 2016
New Revision: 294593
URL: https://svnweb.freebsd.org/changeset/base/294593
Log:
sh: Clean a readonly local, even if the variable does not exist outside.
If a local variable has been made read-only, this should not prevent its
removal when the function returns.
Added:
head/bin/sh/tests/builtins/local7.0 (contents, props changed)
Modified:
head/bin/sh/tests/builtins/Makefile
head/bin/sh/var.c
Modified: head/bin/sh/tests/builtins/Makefile
==============================================================================
--- head/bin/sh/tests/builtins/Makefile Fri Jan 22 19:43:26 2016 (r294592)
+++ head/bin/sh/tests/builtins/Makefile Fri Jan 22 20:10:08 2016 (r294593)
@@ -113,6 +113,7 @@ FILES+= local3.0
FILES+= local4.0
FILES+= local5.0
FILES+= local6.0
+FILES+= local7.0
.if ${MK_NLS} != "no"
FILES+= locale1.0
.endif
Added: head/bin/sh/tests/builtins/local7.0
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/bin/sh/tests/builtins/local7.0 Fri Jan 22 20:10:08 2016 (r294593)
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+f() {
+ local x
+ readonly x=2
+}
+unset x
+f
+x=4
+[ "$x" = 4 ]
Modified: head/bin/sh/var.c
==============================================================================
--- head/bin/sh/var.c Fri Jan 22 19:43:26 2016 (r294592)
+++ head/bin/sh/var.c Fri Jan 22 20:10:08 2016 (r294593)
@@ -802,6 +802,7 @@ poplocalvars(void)
ckfree(lvp->text);
optschanged();
} else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
+ vp->flags &= ~VREADONLY;
(void)unsetvar(vp->text);
} else {
islocalevar = (vp->flags | lvp->flags) & VEXPORT &&
More information about the svn-src-all
mailing list