aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-08-05 15:58:13 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-08-05 18:11:15 +0200
commit58eb805c2c453c6764acbd65f5604465438d9272 (patch)
tree3095b6d1dc10310953ec48ffb5b964bf01319993
parent19358cc31317dca4642417066c1445ce00438e18 (diff)
downloadbusybox-w32-58eb805c2c453c6764acbd65f5604465438d9272.tar.gz
busybox-w32-58eb805c2c453c6764acbd65f5604465438d9272.tar.bz2
busybox-w32-58eb805c2c453c6764acbd65f5604465438d9272.zip
ash: parser: Fix parsing of ${}
Upstream commit: Date: Tue, 3 Apr 2018 00:40:25 +0800 parser: Fix parsing of ${} 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> function old new delta readtoken1 2907 2916 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index f74bef6b1..b596833e7 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -12431,7 +12431,7 @@ parsesub: {
12431 STPUTC(c, out); 12431 STPUTC(c, out);
12432 c = pgetc_eatbnl(); 12432 c = pgetc_eatbnl();
12433 } while (isdigit(c)); 12433 } while (isdigit(c));
12434 } else { 12434 } else if (c != '}') {
12435 /* $[{[#]]<specialchar>[}] */ 12435 /* $[{[#]]<specialchar>[}] */
12436 int cc = c; 12436 int cc = c;
12437 12437
@@ -12457,7 +12457,8 @@ parsesub: {
12457 } 12457 }
12458 12458
12459 USTPUTC(cc, out); 12459 USTPUTC(cc, out);
12460 } 12460 } else
12461 goto badsub;
12461 12462
12462 if (c != '}' && subtype == VSLENGTH) { 12463 if (c != '}' && subtype == VSLENGTH) {
12463 /* ${#VAR didn't end with } */ 12464 /* ${#VAR didn't end with } */