Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Jan 2016 20:10:09 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r294593 - in head/bin/sh: . tests/builtins
Message-ID:  <201601222010.u0MKA9NN005737@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 &&



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601222010.u0MKA9NN005737>