summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-10-29 21:06:57 +0000
committerjilles <jilles@FreeBSD.org>2010-10-29 21:06:57 +0000
commitf98d5a366d0955796050831449d7e3a00bff72f0 (patch)
treebacab176410f6d7063e37520a0642cc6301fa77c /bin
parentc04eb1485ee1de789ea5d17180454ef98f238237 (diff)
downloadFreeBSD-src-f98d5a366d0955796050831449d7e3a00bff72f0.zip
FreeBSD-src-f98d5a366d0955796050831449d7e3a00bff72f0.tar.gz
sh: Detect various additional errors in the parser.
Apart from detecting breakage earlier or at all, this also fixes a segfault in the testsuite. The "handling" of the breakage left an invalid internal representation in some cases. Examples: echo a; do echo b echo `) echo a` echo `date; do do do` Exp-run done by: pav (with some other sh(1) changes)
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/parser.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index 0540dd6..fa670f1 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -220,7 +220,7 @@ parsecmd(int interact)
if (t == TNL)
return NULL;
tokpushback++;
- return list(1, 0);
+ return list(1, 1);
}
@@ -231,7 +231,7 @@ list(int nlflag, int erflag)
int tok;
checkkwd = 2;
- if (nlflag == 0 && tokendlist[peektoken()])
+ if (!nlflag && !erflag && tokendlist[peektoken()])
return NULL;
n1 = NULL;
for (;;) {
@@ -277,7 +277,7 @@ list(int nlflag, int erflag)
tokpushback++;
}
checkkwd = 2;
- if (tokendlist[peektoken()])
+ if (!nlflag && !erflag && tokendlist[peektoken()])
return n1;
break;
case TEOF:
OpenPOWER on IntegriCloud