From cfdacc16eafdd7314befad2621af41af04f0f8b1 Mon Sep 17 00:00:00 2001 From: joerg Date: Sun, 10 Dec 1995 17:59:23 +0000 Subject: The shell incorrectly gave & precedence over ;. This breaks the traditional behaviour, and it violates Posix.2. Fixes PR # bin/880: /bin/sh incorrectly parse... Fixes also an earlier problem report about the shell not evaluating loops correctly. (Not files via GNATS.) Submitted by: nnd@itfs.nsk.su (Nickolay N. Dudorov) --- bin/sh/parser.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 067faa7..c8ea376 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: parser.c,v 1.8 1995/08/27 20:26:42 joerg Exp $ + * $Id: parser.c,v 1.9 1995/08/28 19:24:35 joerg Exp $ */ #ifndef lint @@ -149,30 +149,13 @@ list(nlflag) { n1 = andor(); for (;;) { switch (readtoken()) { - case TBACKGND: - if (n1->type == NCMD || n1->type == NPIPE) { - n1->ncmd.backgnd = 1; - } else if (n1->type == NREDIR) { - n1->type = NBACKGND; - } else { - n3 = (union node *)stalloc(sizeof (struct nredir)); - n3->type = NBACKGND; - n3->nredir.n = n1; - n3->nredir.redirect = NULL; - n1 = n3; - } - goto tsemi; case TNL: - tokpushback++; + parseheredoc(); + if (nlflag) + return n1; /* fall through */ -tsemi: case TSEMI: - if (readtoken() == TNL) { - parseheredoc(); - if (nlflag) - return n1; - } else { - tokpushback++; - } + case TBACKGND: + case TSEMI: checkkwd = 2; if (tokendlist[peektoken()]) return n1; @@ -212,6 +195,19 @@ andor() { } else if (t == TOR) { t = NOR; } else { + if (t == TBACKGND) { + if (n1->type == NCMD || n1->type == NPIPE) { + n1->ncmd.backgnd = 1; + } else if (n1->type == NREDIR) { + n1->type = NBACKGND; + } else { + n3 = (union node *)stalloc(sizeof (struct nredir)); + n3->type = NBACKGND; + n3->nredir.n = n1; + n3->nredir.redirect = NULL; + n1 = n3; + } + } tokpushback++; return n1; } -- cgit v1.1