diff options
| author | Nikolai Merinov <n.merinov@inango-systems.com> | 2019-04-29 19:13:37 +0500 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2020-01-20 17:52:07 +0800 |
| commit | c4f4ee8ecf85834811c252fc1df3892863572bbd (patch) | |
| tree | 2f377c0f421747e5c8656c636730a824c59de625 | |
| parent | parser: Fix old-style command substitution here-document crash (diff) | |
| download | dash-c4f4ee8ecf85834811c252fc1df3892863572bbd.tar.gz dash-c4f4ee8ecf85834811c252fc1df3892863572bbd.zip | |
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>
Diffstat (limited to '')
| -rw-r--r-- | src/expand.c | 2 |
1 files changed, 1 insertions, 1 deletions
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; |