diff options
Diffstat (limited to 'bin/sh/parser.c')
| -rw-r--r-- | bin/sh/parser.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c index dc0e046ea171..1ab8751d0c7e 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -352,10 +352,11 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); n2->narg.backquote = NULL; n2->narg.next = NULL; n1->nfor.args = n2; - /* A newline or semicolon is optional here. Anything - else gets pushed back so we can read it again. */ - if (lasttoken != TNL && lasttoken != TSEMI) - tokpushback++; + /* Many shells accept an optional semicolon here, but + POSIX says we should not, so we don't. An optional + newline is OK here, but that is handled by the + checkkwd = 2 assignment below. */ + tokpushback++; } checkkwd = 2; if ((t = readtoken()) == TDO) @@ -429,7 +430,10 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); checkkwd = 1; break; /* Handle an empty command like other simple commands. */ + case TSEMI: case TNL: + /* Handle EOF like other simple commands, too. */ + case TEOF: case TWORD: tokpushback++; return simplecmd(rpp, redir); |
