diff options
author | Nikolai Merinov <n.merinov@inango-systems.com> | 2019-04-29 19:13:37 +0500 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-03-28 21:42:55 +0000 |
commit | 42c84c0c2ed8f5b9a81bd70582edfa9d7ead08be (patch) | |
tree | 06a30e4a85195fbf794375eb3f3acb50a44e33a6 | |
parent | 0274540a8baa08929dbdcf367c505a46d659b44c (diff) | |
download | klibc-42c84c0c2ed8f5b9a81bd70582edfa9d7ead08be.tar.gz |
[klibc] dash: expand: Fix trailing newlines processing in backquote expanding
[ dash commit c4f4ee8ecf85834811c252fc1df3892863572bbd ]
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: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/dash/expand.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/usr/dash/expand.c b/usr/dash/expand.c index 562a48690af01..175f037bb3594 100644 --- a/usr/dash/expand.c +++ b/usr/dash/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; |