From 427748f7df4c95b955328061873a0716a0643b0b Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Sun, 6 Oct 2002 06:35:51 +0000 Subject: 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. --- bin/sh/parser.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 4df742d34162..e00df92aab86 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); -- cgit v1.3