aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-01-09 08:46:54 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-01-09 08:46:54 +0100
commit2b7c1aa92c68524559a2067609d09309d5c09adc (patch)
treef82686a7f0d2042a0a741eeb707ff64190434a89
parent883cdb79a440d0425766f67aaef0cabde0a5060e (diff)
downloadbusybox-w32-2b7c1aa92c68524559a2067609d09309d5c09adc.tar.gz
busybox-w32-2b7c1aa92c68524559a2067609d09309d5c09adc.tar.bz2
busybox-w32-2b7c1aa92c68524559a2067609d09309d5c09adc.zip
ash: match bash behavior for ${empty_var/*/repl}
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c6
-rw-r--r--shell/ash_test/ash-vars/var_bash_repl_empty_var.right2
2 files changed, 4 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 76bf39ec2..1aead6df4 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7178,7 +7178,7 @@ subevalvar(char *start, char *str, int strloc,
7178 len = 0; 7178 len = 0;
7179 idx = startp; 7179 idx = startp;
7180 end = str - 1; 7180 end = str - 1;
7181 while (idx < end) { 7181 while (idx <= end) {
7182 try_to_match: 7182 try_to_match:
7183 loc = scanright(idx, rmesc, rmescend, str, quotes, 1); 7183 loc = scanright(idx, rmesc, rmescend, str, quotes, 1);
7184 //bb_error_msg("scanright('%s'):'%s'", str, loc); 7184 //bb_error_msg("scanright('%s'):'%s'", str, loc);
@@ -7186,6 +7186,8 @@ subevalvar(char *start, char *str, int strloc,
7186 /* No match, advance */ 7186 /* No match, advance */
7187 char *restart_detect = stackblock(); 7187 char *restart_detect = stackblock();
7188 skip_matching: 7188 skip_matching:
7189 if (idx >= end)
7190 break;
7189 STPUTC(*idx, expdest); 7191 STPUTC(*idx, expdest);
7190 if (quotes && (unsigned char)*idx == CTLESC) { 7192 if (quotes && (unsigned char)*idx == CTLESC) {
7191 idx++; 7193 idx++;
@@ -7198,8 +7200,6 @@ subevalvar(char *start, char *str, int strloc,
7198 len++; 7200 len++;
7199 rmesc++; 7201 rmesc++;
7200 /* continue; - prone to quadratic behavior, smarter code: */ 7202 /* continue; - prone to quadratic behavior, smarter code: */
7201 if (idx >= end)
7202 break;
7203 if (str[0] == '*') { 7203 if (str[0] == '*') {
7204 /* Pattern is "*foo". If "*foo" does not match "long_string", 7204 /* Pattern is "*foo". If "*foo" does not match "long_string",
7205 * it would never match "ong_string" etc, no point in trying. 7205 * it would never match "ong_string" etc, no point in trying.
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 cf8f088c1..a8d1a3bef 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,3 +1,3 @@
1 1
2 2w
3Ok:0 3Ok:0