[klibc] [klibc:update-dash] parser: Allow newlines within parameter substitution
klibc-bot for Herbert Xu
herbert at gondor.apana.org.au
Thu Jan 24 19:15:54 PST 2019
Commit-ID: 5be21a4b26eb56c7d84544b30353920b35693614
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=5be21a4b26eb56c7d84544b30353920b35693614
Author: Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Thu, 22 Mar 2018 21:41:24 +0800
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 25 Jan 2019 02:57:21 +0000
[klibc] 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 at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/dash/parser.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/usr/dash/parser.c b/usr/dash/parser.c
index ae76400e..6a8a4a43 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();
More information about the klibc
mailing list