aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-23 12:38:03 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-23 12:38:03 +0100
commita7b52d26c435c35336ddc5ff93d5680e648345c8 (patch)
tree0622a61c2da67a946411501c10a44a2889f994dc
parent93e2a22482b72b3076377f71347e3dd07d7dd2f8 (diff)
downloadbusybox-w32-a7b52d26c435c35336ddc5ff93d5680e648345c8.tar.gz
busybox-w32-a7b52d26c435c35336ddc5ff93d5680e648345c8.tar.bz2
busybox-w32-a7b52d26c435c35336ddc5ff93d5680e648345c8.zip
hush: fix fallout from tweaking ${var:START:LEN} code
function old new delta expand_one_var 2344 2353 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c2
-rw-r--r--shell/hush_test/hush-vars/var_bash_repl_empty_var.right1
-rwxr-xr-xshell/hush_test/hush-vars/var_bash_repl_empty_var.tests2
3 files changed, 4 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 6b8f1c88c..9403e1f6c 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -6617,7 +6617,7 @@ static NOINLINE int expand_one_var(o_string *output, int n,
6617 exp_word = p; 6617 exp_word = p;
6618 p = strchr(p, SPECIAL_VAR_SYMBOL); 6618 p = strchr(p, SPECIAL_VAR_SYMBOL);
6619 *p = '\0'; 6619 *p = '\0';
6620 vallen = strlen(val); 6620 vallen = val ? strlen(val) : 0;
6621 if (beg < 0) { 6621 if (beg < 0) {
6622 /* negative beg counts from the end */ 6622 /* negative beg counts from the end */
6623 beg = (arith_t)vallen + beg; 6623 beg = (arith_t)vallen + beg;
diff --git a/shell/hush_test/hush-vars/var_bash_repl_empty_var.right b/shell/hush_test/hush-vars/var_bash_repl_empty_var.right
index 892916783..a8d1a3bef 100644
--- a/shell/hush_test/hush-vars/var_bash_repl_empty_var.right
+++ b/shell/hush_test/hush-vars/var_bash_repl_empty_var.right
@@ -1,2 +1,3 @@
1 1
2w
2Ok:0 3Ok:0
diff --git a/shell/hush_test/hush-vars/var_bash_repl_empty_var.tests b/shell/hush_test/hush-vars/var_bash_repl_empty_var.tests
index 73a43d38e..22aaba560 100755
--- a/shell/hush_test/hush-vars/var_bash_repl_empty_var.tests
+++ b/shell/hush_test/hush-vars/var_bash_repl_empty_var.tests
@@ -1,3 +1,5 @@
1unset v
2echo ${v/*/w}
1v='' 3v=''
2echo ${v/*/w} 4echo ${v/*/w}
3echo Ok:$? 5echo Ok:$?