aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-02-17 10:24:32 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-02-17 10:24:32 +0100
commit9ee5892798be81f7a6f3e070ecd52cbf0d55740e (patch)
tree9801edcaadd307687df6f33cad7ba7edd1e2b75b /shell/ash.c
parentc2ce888030b6b880b3229520a8ff7d7026248a9a (diff)
downloadbusybox-9ee5892798be81f7a6f3e070ecd52cbf0d55740e.tar.gz
ash: expand: Fix trailing newlines processing in backquote expanding
Upstream commit: Date: Mon, 29 Apr 2019 19:13:37 +0500 expand: Fix trailing newlines processing in backquote expanding According to POSIX.1-2008 we should remove newlines only at the end of the substitution. Newlines-only substitions causes dash to remove newlines before beggining of the substitution. The following code: cat <<END 1 $(echo "") 2 END prints "1<newline>2" instead of expected "1<newline><newline>2". This patch fixes trailing newlines processing in backquote expanding. Signed-off-by: Nikolai Merinov <n.merinov@inango-systems.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 90496ba7e..dfe6d1c48 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6578,7 +6578,7 @@ expbackq(union node *cmd, int flag)
/* Eat all trailing newlines */
dest = expdest;
- for (; dest > (char *)stackblock() && dest[-1] == '\n';)
+ for (; dest > ((char *)stackblock() + startloc) && dest[-1] == '\n';)
STUNPUTC(dest);
expdest = dest;