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.
This commit is contained in:
Jilles Tjoelker 2016-01-22 20:10:08 +00:00
parent de80c945d2
commit a9bdd616f9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=294593
3 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,10 @@
# $FreeBSD$
f() {
local x
readonly x=2
}
unset x
f
x=4
[ "$x" = 4 ]

View File

@ -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 &&