aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-01-26 10:37:03 +0000
committerRon Yorston <rmy@pobox.com>2019-01-26 10:37:03 +0000
commit0aad680ce3c01a23fbcef8f67ed160e09936ab17 (patch)
treef82033304fc2679f7adf883c5a6c51d8a4b530de
parent7874ca73b5cc8cfbf8a9151c34747aac4a1792f4 (diff)
downloadbusybox-w32-0aad680ce3c01a23fbcef8f67ed160e09936ab17.tar.gz
busybox-w32-0aad680ce3c01a23fbcef8f67ed160e09936ab17.tar.bz2
busybox-w32-0aad680ce3c01a23fbcef8f67ed160e09936ab17.zip
ash: remove carriage returns from strings to be evaluated
The shell could fail to evaluate strings containing carriage returns. For example: awk 'BEGIN { "set -ex\r\npwd\r\n" | getline }' </dev/null The string is passed as an argument to "sh -c". The "set" built-in fails because it attempts to treat the carriage return as an option. Although this is correct behaviour on Unix it may be unhelpful on Microsoft Windows. See GitHub issue #138.
-rw-r--r--shell/ash.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 50d5ce9d4..6283d3c28 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13614,6 +13614,18 @@ evalstring(char *s, int flags)
13614 int status; 13614 int status;
13615 13615
13616 s = sstrdup(s); 13616 s = sstrdup(s);
13617#if ENABLE_PLATFORM_MINGW32
13618 {
13619 char *t, *u;
13620
13621 for (t=u=s; *t; ++t) {
13622 if (*t != '\r') {
13623 *u++ = *t;
13624 }
13625 }
13626 *u = '\0';
13627 }
13628#endif
13617 setinputstring(s); 13629 setinputstring(s);
13618 setstackmark(&smark); 13630 setstackmark(&smark);
13619 13631