diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2018-04-03 01:04:55 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-04-19 18:19:30 +0800 |
commit | 48ca00863af909461d1372998bb90549f27abaaf (patch) | |
tree | 520593b8f7a0350d8ac3fd8016a2349935429b63 | |
parent | 6348e861b20d0b90275970af7357ac35ef956f16 (diff) | |
download | dash-48ca00863af909461d1372998bb90549f27abaaf.tar.gz |
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>
-rw-r--r-- | src/parser.c | 5 |
1 files changed, 3 insertions, 2 deletions
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)), |