From 48ca00863af909461d1372998bb90549f27abaaf Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 3 Apr 2018 01:04:55 +0800 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 Fixes: ab1cecb40478 (" parser: Add syntax stack for recursive...") Signed-off-by: Herbert Xu --- src/parser.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/parser.c') diff --git a/src/parser.c b/src/parser.c index efa8060..8e40781 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1325,10 +1325,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)), -- cgit 1.4.1