ash: make "locak VAR" unset VAR (bash does that)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2014-03-16 18:41:11 +01:00
parent 438b4ac286
commit 109ee5d336
3 changed files with 18 additions and 0 deletions

View File

@ -8960,6 +8960,9 @@ mklocal(char *name)
vp->flags |= VSTRFIXED|VTEXTFIXED;
if (eq)
setvareq(name, 0);
else
/* "local VAR" unsets VAR: */
setvar(name, NULL, 0);
}
}
lvp->vp = vp;

View File

@ -0,0 +1,4 @@
A1:'A'
A2:''
A3:''
A4:'A'

View File

@ -0,0 +1,11 @@
a=A
f() {
local a
# the above line unsets $a
echo "A2:'$a'"
unset a
echo "A3:'$a'"
}
echo "A1:'$a'"
f
echo "A4:'$a'"