From b785bd7d3ba581400e96c38b5c948b59a50e0b42 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Mon, 9 Apr 2001 12:46:19 +0000 Subject: ``|'' should be more binding than ``!'' so that this isn't broken: if ! echo bla | wc -c ; then echo broken fi Obtained from: NetBSD --- bin/sh/parser.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'bin/sh') diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 0c9a202271bd..e1c05720a167 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -253,10 +253,15 @@ andor() { STATIC union node * pipeline() { - union node *n1, *pipenode; + union node *n1, *n2, *pipenode; struct nodelist *lp, *prev; + int negate; + negate = 0; TRACE(("pipeline: entered\n")); + while (readtoken() == TNOT) + negate = !negate; + tokpushback++; n1 = command(); if (readtoken() == TPIPE) { pipenode = (union node *)stalloc(sizeof (struct npipe)); @@ -275,7 +280,13 @@ pipeline() { n1 = pipenode; } tokpushback++; - return n1; + if (negate) { + n2 = (union node *)stalloc(sizeof (struct nnot)); + n2->type = NNOT; + n2->nnot.com = n1; + return n2; + } else + return n1; } -- cgit v1.2.3