[git commit branch/1_32_stable] ash: fix ${unset_var/pattern/repl}

Denys Vlasenko vda.linux at googlemail.com
Tue Mar 30 13:17:12 UTC 2021


commit: https://git.busybox.net/busybox/commit/?id=30ffa2bb15956d5779fd1984c698621386bae9c1
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/1_32_stable

function                                             old     new   delta
subevalvar                                          1349    1353      +4

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c                                           | 3 ++-
 shell/ash_test/ash-vars/var_bash_repl_empty_var.right | 1 +
 shell/ash_test/ash-vars/var_bash_repl_empty_var.tests | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/shell/ash.c b/shell/ash.c
index 07aa2da2e..00b33cc86 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7011,7 +7011,8 @@ subevalvar(char *start, char *str, int strloc,
 	slash_pos = -1;
 	if (repl) {
 		slash_pos = expdest - ((char *)stackblock() + strloc);
-		STPUTC('/', expdest);
+		if (!(flag & EXP_DISCARD))
+			STPUTC('/', expdest);
 		//bb_error_msg("repl+1:'%s'", repl + 1);
 		p = argstr(repl + 1, (flag & EXP_DISCARD) | EXP_TILDE); /* EXP_TILDE: echo "${v/x/~}" expands ~ ! */
 		*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 @@
 
+
 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 @@
+unset v
+echo ${v/*/w}
 v=''
 echo ${v/*/w}
 echo Ok:$?


More information about the busybox-cvs mailing list