diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-01-09 08:27:37 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-05-03 20:06:49 +0200 |
commit | 611bbfc148477aec863454dd85e6f1bfe5770332 (patch) | |
tree | 9e7c92c666a767708ee97119acdadefa43f2262d | |
parent | 23dd1c75b7457f08f1c55a95f3c2fb6faf742562 (diff) | |
download | busybox-w32-611bbfc148477aec863454dd85e6f1bfe5770332.tar.gz busybox-w32-611bbfc148477aec863454dd85e6f1bfe5770332.tar.bz2 busybox-w32-611bbfc148477aec863454dd85e6f1bfe5770332.zip |
ash: fix ${unset_var/pattern/repl}
function old new delta
subevalvar 1349 1353 +4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 3 | ||||
-rw-r--r-- | shell/ash_test/ash-vars/var_bash_repl_empty_var.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-vars/var_bash_repl_empty_var.tests | 2 |
3 files changed, 5 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c index ecbfbf091..a33ab0626 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -7011,7 +7011,8 @@ subevalvar(char *start, char *str, int strloc, | |||
7011 | slash_pos = -1; | 7011 | slash_pos = -1; |
7012 | if (repl) { | 7012 | if (repl) { |
7013 | slash_pos = expdest - ((char *)stackblock() + strloc); | 7013 | slash_pos = expdest - ((char *)stackblock() + strloc); |
7014 | STPUTC('/', expdest); | 7014 | if (!(flag & EXP_DISCARD)) |
7015 | STPUTC('/', expdest); | ||
7015 | //bb_error_msg("repl+1:'%s'", repl + 1); | 7016 | //bb_error_msg("repl+1:'%s'", repl + 1); |
7016 | p = argstr(repl + 1, (flag & EXP_DISCARD) | EXP_TILDE); /* EXP_TILDE: echo "${v/x/~}" expands ~ ! */ | 7017 | p = argstr(repl + 1, (flag & EXP_DISCARD) | EXP_TILDE); /* EXP_TILDE: echo "${v/x/~}" expands ~ ! */ |
7017 | *repl = '/'; | 7018 | *repl = '/'; |
diff --git a/shell/ash_test/ash-vars/var_bash_repl_empty_var.right b/shell/ash_test/ash-vars/var_bash_repl_empty_var.right index 892916783..cf8f088c1 100644 --- a/shell/ash_test/ash-vars/var_bash_repl_empty_var.right +++ b/shell/ash_test/ash-vars/var_bash_repl_empty_var.right | |||
@@ -1,2 +1,3 @@ | |||
1 | 1 | ||
2 | |||
2 | Ok:0 | 3 | Ok:0 |
diff --git a/shell/ash_test/ash-vars/var_bash_repl_empty_var.tests b/shell/ash_test/ash-vars/var_bash_repl_empty_var.tests index 73a43d38e..22aaba560 100755 --- a/shell/ash_test/ash-vars/var_bash_repl_empty_var.tests +++ b/shell/ash_test/ash-vars/var_bash_repl_empty_var.tests | |||
@@ -1,3 +1,5 @@ | |||
1 | unset v | ||
2 | echo ${v/*/w} | ||
1 | v='' | 3 | v='' |
2 | echo ${v/*/w} | 4 | echo ${v/*/w} |
3 | echo Ok:$? | 5 | echo Ok:$? |