aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-03-22 21:41:24 +0800
committerBen Hutchings <ben@decadent.org.uk>2020-03-28 21:42:54 +0000
commitc4e624f2b9b9aa1cd9b6f6a79a7529aa21275b9c (patch)
tree2954eadb6db89d6f12fa40033c0c35a97a5f3dd1
parentf4d7a34b1ec9a2238179a48eac757478736c9ca6 (diff)
downloadklibc-c4e624f2b9b9aa1cd9b6f6a79a7529aa21275b9c.tar.gz
[klibc] dash: parser: Allow newlines within parameter substitution
[ dash commit dad1cb18b60ecce925f4ed234553a43fa6c81447 ] On Fri, Mar 16, 2018 at 11:27:22AM +0800, Herbert Xu wrote: > On Thu, Mar 15, 2018 at 10:49:15PM +0100, Harald van Dijk wrote: > > > > Okay, it can be trivially modified to something that does work in other > > shells (even if it were actually executed), but gets rejected at parse time > > by dash: > > > > if false; then > > : ${$+ > > } > > fi > > That's just a bug in dash's parser with ${} in general, because > it bombs out without the if clause too: > > : ${$+ > } This patch fixes the parsing of newlines with parameter substitution. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--usr/dash/parser.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr/dash/parser.c b/usr/dash/parser.c
index ae76400ec8a99..6a8a4a431f9f2 100644
--- a/usr/dash/parser.c
+++ b/usr/dash/parser.c
@@ -924,7 +924,8 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
CHECKSTRSPACE(4, out); /* permit 4 calls to USTPUTC */
switch(synstack->syntax[c]) {
case CNL: /* '\n' */
- if (synstack->syntax == BASESYNTAX)
+ if (synstack->syntax == BASESYNTAX &&
+ !synstack->varnest)
goto endword; /* exit outer loop */
USTPUTC(c, out);
nlprompt();