1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Fri, 17 Apr 2015 01:54:51 +0200
3 Subject: [PATCH] ash: fix a regression in handling local variables
5 commit 109ee5d33694a03cda3424b4846584250832ba8e
6 "ash: make "locak VAR" unset VAR (bash does that)"
8 This commit introduced a regression where calling local on an already
9 local variable unsets it. This does not match bash behavior.
11 Update test case to check for this behavior
13 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
18 @@ -8961,6 +8961,21 @@ parse_command_args(char **argv, const ch
23 +findlocal(struct var *vp)
25 + struct localvar *lvp = localvars;
38 * Make a variable a local variable. When a variable is made local, it's
39 * value and flags are saved in a localvar structure. The saved values
40 @@ -9000,7 +9015,7 @@ mklocal(char *name)
41 vp->flags |= VSTRFIXED|VTEXTFIXED;
45 + else if (!findlocal(vp))
46 /* "local VAR" unsets VAR: */
47 setvar(name, NULL, 0);
49 --- a/shell/ash_test/ash-misc/local1.right
50 +++ b/shell/ash_test/ash-misc/local1.right
59 --- a/shell/ash_test/ash-misc/local1.tests
60 +++ b/shell/ash_test/ash-misc/local1.tests
61 @@ -3,9 +3,12 @@ f() {
63 # the above line unsets $a