Module Name:    src
Committed By:   kre
Date:           Tue May  9 03:38:24 UTC 2017

Modified Files:
        src/bin/sh: eval.c

Log Message:
Fix some bogus usage of EV_EXIT in evaltree().   Fix (somewhat) inspired
by FreeBSD sh (though different, for other reasons) - but the bug discovered
while searching for why a (nonsense) attempted test of the forthcoming
code to handle "! ! pipeline" properly wasn't working...  (it was how I was
testing it that was broken, but until I achieved enlightenment, I was bug
hunting, and found this...)

Most likely the bugs here wouldn't have affected any real code (no bug
reports anyway), but ...


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/bin/sh/eval.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/eval.c
diff -u src/bin/sh/eval.c:1.135 src/bin/sh/eval.c:1.136
--- src/bin/sh/eval.c:1.135	Sun May  7 10:37:00 2017
+++ src/bin/sh/eval.c	Tue May  9 03:38:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.c,v 1.135 2017/05/07 10:37:00 kre Exp $	*/
+/*	$NetBSD: eval.c,v 1.136 2017/05/09 03:38:24 kre Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)eval.c	8.9 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: eval.c,v 1.135 2017/05/07 10:37:00 kre Exp $");
+__RCSID("$NetBSD: eval.c,v 1.136 2017/05/09 03:38:24 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -239,6 +239,7 @@ void
 evaltree(union node *n, int flags)
 {
 	bool do_etest;
+	int sflags = flags & ~EV_EXIT;
 
 	do_etest = false;
 	if (n == NULL || nflag) {
@@ -259,7 +260,7 @@ evaltree(union node *n, int flags)
 #endif
 	switch (n->type) {
 	case NSEMI:
-		evaltree(n->nbinary.ch1, (flags & EV_TESTED) |
+		evaltree(n->nbinary.ch1, (sflags & EV_TESTED) |
 		    (n->nbinary.ch2 ? EV_MORE : 0));
 		if (nflag || evalskip)
 			goto out;
@@ -304,20 +305,20 @@ evaltree(union node *n, int flags)
 	}
 	case NWHILE:
 	case NUNTIL:
-		evalloop(n, flags);
+		evalloop(n, sflags);
 		break;
 	case NFOR:
-		evalfor(n, flags);
+		evalfor(n, sflags);
 		break;
 	case NCASE:
-		evalcase(n, flags);
+		evalcase(n, sflags);
 		break;
 	case NDEFUN:
 		defun(n->narg.text, n->narg.next);
 		exitstatus = 0;
 		break;
 	case NNOT:
-		evaltree(n->nnot.com, (flags & EV_MORE) | EV_TESTED);
+		evaltree(n->nnot.com, (sflags & EV_MORE) | EV_TESTED);
 		exitstatus = !exitstatus;
 		break;
 	case NPIPE:

Reply via email to