Message ID | 20180402170455.GA750@gondor.apana.org.au (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Herbert Xu |
Headers | show |
On Mon, Apr 2, 2018 at 7:04 PM, Herbert Xu <herbert@gondor.apana.org.au> wrote: > On Mon, Apr 02, 2018 at 02:13:03PM +0200, Denys Vlasenko wrote: >> >> I was trying some of the beautiful atrocities from one of earlier >> Harald's emails and this one fails in current dash git: >> >> # x="''''"; echo "${x#"${x+''}"''}" >> dash: 12: Syntax error: Missing '}' > > Thanks for the report. This patch should fix it. > > ---8<--- > Subject: parser: Fix parameter expansion inside inner double quotes > > The parsing of parameter expansion inside inner double quotes > breaks because we never look for ENDVAR while innerdq is true. > > echo "${x#"${x+''}"''} > > This patch fixes it by pushing the syntax stack if innerdq is > true and we enter a new parameter expansion. > > This patch also fixes a corner case where a bad substitution error > occurs within arithmetic expansion. > > Reported-by: Denys Vlasenko <vda.linux@googlemail.com> > Fixes: ab1cecb40478 (" parser: Add syntax stack for recursive...") > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> > > diff --git a/src/parser.c b/src/parser.c > index 6a8a4a4..a856458 100644 > --- a/src/parser.c > +++ b/src/parser.c > @@ -1324,10 +1324,11 @@ badsub: > pungetc(); > } > > - if (newsyn == ARISYNTAX && subtype > VSNORMAL) > + if (newsyn == ARISYNTAX) > newsyn = DQSYNTAX; > > - if (newsyn != synstack->syntax) { > + if ((newsyn != synstack->syntax || synstack->innerdq) && > + subtype != VSNORMAL) { > synstack_push(&synstack, > synstack->prev ?: > alloca(sizeof(*synstack)), Verified, thanks! -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/src/parser.c b/src/parser.c index 6a8a4a4..a856458 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1324,10 +1324,11 @@ badsub: pungetc(); } - if (newsyn == ARISYNTAX && subtype > VSNORMAL) + if (newsyn == ARISYNTAX) newsyn = DQSYNTAX; - if (newsyn != synstack->syntax) { + if ((newsyn != synstack->syntax || synstack->innerdq) && + subtype != VSNORMAL) { synstack_push(&synstack, synstack->prev ?: alloca(sizeof(*synstack)),