summaryrefslogtreecommitdiffstats
path: root/lib/readline.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-10-27 10:43:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-27 10:45:39 +0200
commit1498093ccd11596d754ea3cc5c86a4addb970ccc (patch)
tree6168af30b533d43497f33badd3dbb12f1eecba16 /lib/readline.c
parent70e0885229d250c2c4dede0a9513c76c10ad44bd (diff)
downloadbarebox-1498093ccd11596d754ea3cc5c86a4addb970ccc.tar.gz
barebox-1498093ccd11596d754ea3cc5c86a4addb970ccc.tar.xz
readline: Complete strings containing whitespaces correctly
Completion strings containing whitespaces have to end up as a single argv[] argument, thus the whitespaces have to be escaped. Fix this. Ideally the whitespaces should only be escaped when we are outside of double or single quotes, but our completion currently doesn't trigger at all when invokes inside quotes, so we can ignore this case for now. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/readline.c')
-rw-r--r--lib/readline.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/readline.c b/lib/readline.c
index 37d5b0a343..92bec3d1d8 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -230,9 +230,14 @@ int readline(const char *prompt, char *buf, int len)
}
i = 0;
- while (completestr[i])
+ while (completestr[i]) {
+ if (completestr[i] == ' ' && completestr[i + 1])
+ cread_add_char('\\', insert, &num,
+ &eol_num, buf, len);
+
cread_add_char(completestr[i++], insert, &num,
&eol_num, buf, len);
+ }
#endif
break;