aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-04-03 00:40:25 +0800
committerBen Hutchings <ben@decadent.org.uk>2020-03-28 21:42:55 +0000
commit8dfaea787acb1aaf1387af6a81904e0a57746985 (patch)
treed9490fe2955b02539f5590e7ffe84ee6225f5922
parent6b0cf885180cfb08f7ec5139e67e581bbba5d6be (diff)
downloadklibc-8dfaea787acb1aaf1387af6a81904e0a57746985.tar.gz
[klibc] dash: parser: Fix parsing of ${}
[ dash commit 6348e861b20d0b90275970af7357ac35ef956f16 ] dash -c 'echo ${}' should print "Bad subtitution" but instead fails with "Syntax error: Missing '}'". This is caused by us reading an extra character beyond the right brace. This patch fixes it so that this construct only fails during expansion rather than during parsing. Fixes: 3df3edd13389 ("[PARSER] Report substition errors at...") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--usr/dash/parser.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr/dash/parser.c b/usr/dash/parser.c
index 6a8a4a431f9f2..efa8060ffc72f 100644
--- a/usr/dash/parser.c
+++ b/usr/dash/parser.c
@@ -1262,7 +1262,7 @@ varname:
STPUTC(c, out);
c = pgetc_eatbnl();
} while (is_digit(c));
- } else {
+ } else if (c != '}') {
int cc = c;
c = pgetc_eatbnl();
@@ -1290,7 +1290,8 @@ varname:
}
USTPUTC(cc, out);
- }
+ } else
+ goto badsub;
if (subtype == 0) {
int cc = c;