summaryrefslogtreecommitdiffstats
path: root/common/hush.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-11-14 16:54:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-11-14 16:54:37 +0100
commit66544641b2dd00c37e16d8e1ac39a34ec4e57cb8 (patch)
treee6da99bd0d182f7f49a5c414425a4d40265274d4 /common/hush.c
parent5f41ca465e2afae789ac76faa8dcfbac849b4ff9 (diff)
parenta4b49c69c3ad1cf0e92943921a699fbe586b5706 (diff)
downloadbarebox-66544641b2dd00c37e16d8e1ac39a34ec4e57cb8.tar.gz
barebox-66544641b2dd00c37e16d8e1ac39a34ec4e57cb8.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'common/hush.c')
-rw-r--r--common/hush.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/hush.c b/common/hush.c
index 6a089fabf1..5138a1a45a 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;