diff options
author | tjr <tjr@FreeBSD.org> | 2002-10-06 06:35:51 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-10-06 06:35:51 +0000 |
commit | 742de9da6c3be1225671a5605d84562e8049011a (patch) | |
tree | e14d23a8dc39e8999f9cb0b4b2bdb1dc7f1b5480 /bin/sh | |
parent | 9e7f867aa7a090ffb5216bb6ed6d8befc5c93f5d (diff) | |
download | FreeBSD-src-742de9da6c3be1225671a5605d84562e8049011a.zip FreeBSD-src-742de9da6c3be1225671a5605d84562e8049011a.tar.gz |
Disallow empty condition parts of "if", "while" and "until" compound
commands. Commands like "if then ... fi" and "while do ... done" are no
longer accepted. Bodies of compound commands are still allowed to be
empty, because even though POSIX does not allow them, most shells do.
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/parser.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 4df742d..e00df92 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -323,7 +323,8 @@ command(void) case TIF: n1 = (union node *)stalloc(sizeof (struct nif)); n1->type = NIF; - n1->nif.test = list(0); + if ((n1->nif.test = list(0)) == NULL) + synexpect(-1); if (readtoken() != TTHEN) synexpect(TTHEN); n1->nif.ifpart = list(0); @@ -332,7 +333,8 @@ command(void) n2->nif.elsepart = (union node *)stalloc(sizeof (struct nif)); n2 = n2->nif.elsepart; n2->type = NIF; - n2->nif.test = list(0); + if ((n2->nif.test = list(0)) == NULL) + synexpect(-1); if (readtoken() != TTHEN) synexpect(TTHEN); n2->nif.ifpart = list(0); @@ -352,7 +354,8 @@ command(void) int got; n1 = (union node *)stalloc(sizeof (struct nbinary)); n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL; - n1->nbinary.ch1 = list(0); + if ((n1->nbinary.ch1 = list(0)) == NULL) + synexpect(-1); if ((got=readtoken()) != TDO) { TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); synexpect(TDO); |