summaryrefslogtreecommitdiffstats
path: root/bin/sh/parser.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1995-12-10 17:59:23 +0000
committerjoerg <joerg@FreeBSD.org>1995-12-10 17:59:23 +0000
commitcfdacc16eafdd7314befad2621af41af04f0f8b1 (patch)
tree1e3b96cdec210d85b51d6284b650b580c003c0b9 /bin/sh/parser.c
parentfadf68099e5ac47295a9a2cfc5cfb1459cb2f45f (diff)
downloadFreeBSD-src-cfdacc16eafdd7314befad2621af41af04f0f8b1.zip
FreeBSD-src-cfdacc16eafdd7314befad2621af41af04f0f8b1.tar.gz
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)
Diffstat (limited to 'bin/sh/parser.c')
-rw-r--r--bin/sh/parser.c42
1 files 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;
}
OpenPOWER on IntegriCloud