Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Fix some bogus usage of EV_EXIT in evaltree(). Fix ...



details:   https://anonhg.NetBSD.org/src/rev/30d8a977d4cf
branches:  trunk
changeset: 823780:30d8a977d4cf
user:      kre <kre%NetBSD.org@localhost>
date:      Tue May 09 03:38:24 2017 +0000

description:
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 ...

diffstat:

 bin/sh/eval.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (60 lines):

diff -r b7fac8287af7 -r 30d8a977d4cf bin/sh/eval.c
--- a/bin/sh/eval.c     Tue May 09 02:56:44 2017 +0000
+++ b/bin/sh/eval.c     Tue May 09 03:38:24 2017 +0000
@@ -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 @@
 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 @@
 #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 @@
        }
        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:



Home | Main Index | Thread Index | Old Index