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:
parent
de80c945d2
commit
a9bdd616f9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=294593
@ -113,6 +113,7 @@ FILES+= local3.0
|
|||||||
FILES+= local4.0
|
FILES+= local4.0
|
||||||
FILES+= local5.0
|
FILES+= local5.0
|
||||||
FILES+= local6.0
|
FILES+= local6.0
|
||||||
|
FILES+= local7.0
|
||||||
.if ${MK_NLS} != "no"
|
.if ${MK_NLS} != "no"
|
||||||
FILES+= locale1.0
|
FILES+= locale1.0
|
||||||
.endif
|
.endif
|
||||||
|
10
bin/sh/tests/builtins/local7.0
Normal file
10
bin/sh/tests/builtins/local7.0
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# $FreeBSD$
|
||||||
|
|
||||||
|
f() {
|
||||||
|
local x
|
||||||
|
readonly x=2
|
||||||
|
}
|
||||||
|
unset x
|
||||||
|
f
|
||||||
|
x=4
|
||||||
|
[ "$x" = 4 ]
|
@ -802,6 +802,7 @@ poplocalvars(void)
|
|||||||
ckfree(lvp->text);
|
ckfree(lvp->text);
|
||||||
optschanged();
|
optschanged();
|
||||||
} else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
|
} else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
|
||||||
|
vp->flags &= ~VREADONLY;
|
||||||
(void)unsetvar(vp->text);
|
(void)unsetvar(vp->text);
|
||||||
} else {
|
} else {
|
||||||
islocalevar = (vp->flags | lvp->flags) & VEXPORT &&
|
islocalevar = (vp->flags | lvp->flags) & VEXPORT &&
|
||||||
|
Loading…
Reference in New Issue
Block a user