From c4f4ee8ecf85834811c252fc1df3892863572bbd Mon Sep 17 00:00:00 2001 From: Nikolai Merinov Date: Mon, 29 Apr 2019 19:13:37 +0500 Subject: 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 <2" instead of expected "12". This patch fixes trailing newlines processing in backquote expanding. Signed-off-by: Nikolai Merinov Signed-off-by: Herbert Xu --- src/expand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/expand.c') diff --git a/src/expand.c b/src/expand.c index e57efa6..4a5d75a 100644 --- a/src/expand.c +++ b/src/expand.c @@ -525,7 +525,7 @@ read: /* 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; -- cgit 1.4.1