diff options
-rw-r--r-- | bin/sh/parser.c | 12 | ||||
-rw-r--r-- | tools/regression/bin/sh/parser/empty-cmd1.0 | 3 |
2 files changed, 7 insertions, 8 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c index a350b8b..795e3ee 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -573,7 +573,7 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); synexpect(TEND); checkkwd = CHKKWD | CHKALIAS; break; - /* Handle an empty command like other simple commands. */ + /* A simple command must have at least one redirection or word. */ case TBACKGND: case TSEMI: case TAND: @@ -581,16 +581,12 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); case TPIPE: case TENDCASE: case TFALLTHRU: - /* - * An empty command before a ; doesn't make much sense, and - * should certainly be disallowed in the case of `if ;'. - */ + case TEOF: + case TNL: + case TRP: if (!redir) synexpect(-1); - case TNL: - case TEOF: case TWORD: - case TRP: tokpushback++; n1 = simplecmd(rpp, redir); return n1; diff --git a/tools/regression/bin/sh/parser/empty-cmd1.0 b/tools/regression/bin/sh/parser/empty-cmd1.0 new file mode 100644 index 0000000..f8b01e9 --- /dev/null +++ b/tools/regression/bin/sh/parser/empty-cmd1.0 @@ -0,0 +1,3 @@ +# $FreeBSD$ + +! (eval ': || f()') 2>/dev/null |