diff options
Diffstat (limited to 'common/hush.c')
-rw-r--r-- | common/hush.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/common/hush.c b/common/hush.c index 6a089fabf1..608c0e4937 100644 --- a/common/hush.c +++ b/common/hush.c @@ -617,6 +617,7 @@ static int builtin_exit(struct p_context *ctx, struct child_prog *child, static void remove_quotes_in_str(char *src) { char *trg = src; + bool in_double_quotes = false; while (*src) { if (*src == '\'') { @@ -629,6 +630,7 @@ static void remove_quotes_in_str(char *src) /* drop quotes */ if (*src == '"') { + in_double_quotes = !in_double_quotes; src++; continue; } @@ -654,6 +656,13 @@ static void remove_quotes_in_str(char *src) continue; } + /* replace '\ ' with ' ' */ + if (!in_double_quotes && *src == '\\' && *(src + 1) == ' ') { + *trg++ = ' '; + src += 2; + continue; + } + *trg++ = *src++; } *trg = 0; @@ -1828,7 +1837,7 @@ static char **make_list_in(char **inp, char *name) p3 = insert_var_value(inp[i]); p1 = p3; while (*p1) { - if ((*p1 == ' ')) { + if (*p1 == ' ') { p1++; continue; } |