summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-03-22 21:41:24 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2018-04-02 23:30:44 +0800
commitdad1cb18b60ecce925f4ed234553a43fa6c81447 (patch)
treed751e5e28d26eaf70438358c52c58990b60550ea /src
parentexpand: Fix bugs with words connected to the right of $@ (diff)
downloaddash-dad1cb18b60ecce925f4ed234553a43fa6c81447.tar.gz
dash-dad1cb18b60ecce925f4ed234553a43fa6c81447.zip
parser: Allow newlines within parameter substitution
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>
Diffstat (limited to '')
-rw-r--r--src/parser.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/parser.c b/src/parser.c
index ae76400..6a8a4a4 100644
--- a/src/parser.c
+++ b/src/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();
> 2021-01-12Remove hacky tagging from hilexJune McEnroe 2021-01-12Add htagml -iJune McEnroe 2021-01-12Render tag index in HTMLJune McEnroe 2021-01-12Add htagml -xJune McEnroe 2021-01-12Prevent matching the same tag twiceJune McEnroe 2021-01-12Process htagml file line by lineJune McEnroe 2021-01-12Split fields by tab onlyJune McEnroe 2021-01-12List both Makefile and html.sh under README.7June McEnroe 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe 2021-01-09Add c -t flag to print expression typeJune McEnroe 2021-01-05Update taglineJune McEnroe