diff options
-rw-r--r-- | shell/ash.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/shell/ash.c b/shell/ash.c index 16783f2e8..74b1c3aad 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6267,7 +6267,7 @@ varunset(const char *end, const char *var, const char *umsg, int varflags) | |||
6267 | 6267 | ||
6268 | #if ENABLE_ASH_BASH_COMPAT | 6268 | #if ENABLE_ASH_BASH_COMPAT |
6269 | static char * | 6269 | static char * |
6270 | parse_sub_pattern(char *arg, int inquotes) | 6270 | parse_sub_pattern(char *arg, int varflags) |
6271 | { | 6271 | { |
6272 | char *idx, *repl = NULL; | 6272 | char *idx, *repl = NULL; |
6273 | unsigned char c; | 6273 | unsigned char c; |
@@ -6285,7 +6285,7 @@ parse_sub_pattern(char *arg, int inquotes) | |||
6285 | } | 6285 | } |
6286 | } | 6286 | } |
6287 | *idx++ = c; | 6287 | *idx++ = c; |
6288 | if (!inquotes && c == '\\' && arg[1] == '\\') | 6288 | if (!(varflags & VSQUOTE) && c == '\\' && arg[1] == '\\') |
6289 | arg++; /* skip both \\, not just first one */ | 6289 | arg++; /* skip both \\, not just first one */ |
6290 | arg++; | 6290 | arg++; |
6291 | } | 6291 | } |
@@ -6427,7 +6427,7 @@ subevalvar(char *p, char *varname, int strloc, int subtype, | |||
6427 | char *idx, *end; | 6427 | char *idx, *end; |
6428 | 6428 | ||
6429 | if (!repl) { | 6429 | if (!repl) { |
6430 | repl = parse_sub_pattern(str, varflags & VSQUOTE); | 6430 | repl = parse_sub_pattern(str, varflags); |
6431 | //bb_error_msg("repl:'%s'", repl); | 6431 | //bb_error_msg("repl:'%s'", repl); |
6432 | if (!repl) | 6432 | if (!repl) |
6433 | repl = nullstr; | 6433 | repl = nullstr; |
@@ -6496,12 +6496,11 @@ subevalvar(char *p, char *varname, int strloc, int subtype, | |||
6496 | } | 6496 | } |
6497 | 6497 | ||
6498 | if (subtype == VSREPLACE) { | 6498 | if (subtype == VSREPLACE) { |
6499 | //bb_error_msg("tail:'%s', quotes:%x", idx, quotes); | ||
6499 | while (*idx) { | 6500 | while (*idx) { |
6500 | char *restart_detect = stackblock(); | 6501 | char *restart_detect = stackblock(); |
6501 | if (quotes && *idx == '\\') { | 6502 | if (quotes && (unsigned char)*idx == CTLESC) |
6502 | STPUTC(CTLESC, expdest); | 6503 | idx++; |
6503 | len++; | ||
6504 | } | ||
6505 | STPUTC(*idx, expdest); | 6504 | STPUTC(*idx, expdest); |
6506 | if (stackblock() != restart_detect) | 6505 | if (stackblock() != restart_detect) |
6507 | goto restart; | 6506 | goto restart; |