#if ENABLE_ASH_BASH_COMPAT
static char *
-parse_sub_pattern(char *arg, int inquotes)
+parse_sub_pattern(char *arg, int varflags)
{
char *idx, *repl = NULL;
unsigned char c;
}
}
*idx++ = c;
- if (!inquotes && c == '\\' && arg[1] == '\\')
+ if (!(varflags & VSQUOTE) && c == '\\' && arg[1] == '\\')
arg++; /* skip both \\, not just first one */
arg++;
}
char *idx, *end;
if (!repl) {
- repl = parse_sub_pattern(str, varflags & VSQUOTE);
+ repl = parse_sub_pattern(str, varflags);
//bb_error_msg("repl:'%s'", repl);
if (!repl)
repl = nullstr;
}
if (subtype == VSREPLACE) {
+ //bb_error_msg("tail:'%s', quotes:%x", idx, quotes);
while (*idx) {
char *restart_detect = stackblock();
- if (quotes && *idx == '\\') {
- STPUTC(CTLESC, expdest);
- len++;
- }
+ if (quotes && (unsigned char)*idx == CTLESC)
+ idx++;
STPUTC(*idx, expdest);
if (stackblock() != restart_detect)
goto restart;