Source-Changes-HG archive

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

[src/netbsd-8]: src/bin/sh Pull up following revision(s) (requested by kre in...



details:   https://anonhg.NetBSD.org/src/rev/04a4ffae01c3
branches:  netbsd-8
changeset: 851943:04a4ffae01c3
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Aug 25 14:22:49 2018 +0000

description:
Pull up following revision(s) (requested by kre in ticket #983):

        bin/sh/eval.c: revision 1.158
        bin/sh/eval.h: revision 1.21
        bin/sh/main.c: revision 1.74

PR bin/48875

Revert the changes that were made 19 May 2016 (principally eval.c 1.125)
and the bug fixes in subsequent days (eval.c 1.126 and 1.127) and also
update some newer code that was added more recently which acted in
accordance with those changes (make that code be as it would have been
if the changes now being reverted had never been made).

While the changes made did solve the problem, in a sense, they were
never correct (see the PR for some discussion) and it had always been
intended that they be reverted.   However, in practical sh code, no
issues were reported - until just recently - so nothing was done,
until now...

After this commit, the validate_fn_redirects test case of the sh ATF
test t_redir will fail.   In particular, the subtest of that test
case which is described in the source (of the test) as:

        This one is the real test for PR bin/48875

will fail.

Alternative changes, not to "fix" the problem in the PR, but to
often avoid it will be coming very soon - after which that ATF
test will succeed again.

XXX pullup-8

diffstat:

 bin/sh/eval.c |  43 +++++++++++++++++--------------------------
 bin/sh/eval.h |   3 +--
 bin/sh/main.c |   6 +++---
 3 files changed, 21 insertions(+), 31 deletions(-)

diffs (200 lines):

diff -r 828916efc094 -r 04a4ffae01c3 bin/sh/eval.c
--- a/bin/sh/eval.c     Sat Aug 25 11:45:40 2018 +0000
+++ b/bin/sh/eval.c     Sat Aug 25 14:22:49 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eval.c,v 1.140.2.4 2018/08/25 11:45:40 martin Exp $    */
+/*     $NetBSD: eval.c,v 1.140.2.5 2018/08/25 14:22:49 martin 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.140.2.4 2018/08/25 11:45:40 martin Exp $");
+__RCSID("$NetBSD: eval.c,v 1.140.2.5 2018/08/25 14:22:49 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -221,7 +221,7 @@
        while ((n = parsecmd(0)) != NEOF) {
                XTRACE(DBG_EVAL, ("evalstring: "), showtree(n));
                if (n && nflag == 0)
-                       evaltree(n, flag | EV_MORE);
+                       evaltree(n, flag);
                popstackmark(&smark);
        }
        popfile();
@@ -256,20 +256,19 @@
            getpid(), n, NODETYPENAME(n->type), n->type, flags));
        switch (n->type) {
        case NSEMI:
-               evaltree(n->nbinary.ch1, (sflags & EV_TESTED) |
-                   (n->nbinary.ch2 ? EV_MORE : 0));
+               evaltree(n->nbinary.ch1, flags & EV_TESTED);
                if (nflag || evalskip)
                        goto out;
                evaltree(n->nbinary.ch2, flags);
                break;
        case NAND:
-               evaltree(n->nbinary.ch1, EV_TESTED | EV_MORE);
+               evaltree(n->nbinary.ch1, EV_TESTED);
                if (nflag || evalskip || exitstatus != 0)
                        goto out;
                evaltree(n->nbinary.ch2, flags);
                break;
        case NOR:
-               evaltree(n->nbinary.ch1, EV_TESTED | EV_MORE);
+               evaltree(n->nbinary.ch1, EV_TESTED);
                if (nflag || evalskip || exitstatus == 0)
                        goto out;
                evaltree(n->nbinary.ch2, flags);
@@ -296,14 +295,14 @@
                }
                break;
        case NSUBSHELL:
-               evalsubshell(n, flags & ~EV_MORE);
+               evalsubshell(n, flags);
                do_etest = !(flags & EV_TESTED);
                break;
        case NBACKGND:
-               evalsubshell(n, flags & ~EV_MORE);
+               evalsubshell(n, flags);
                break;
        case NIF: {
-               evaltree(n->nif.test, EV_TESTED | EV_MORE);
+               evaltree(n->nif.test, EV_TESTED);
                if (nflag || evalskip)
                        goto out;
                if (exitstatus == 0)
@@ -331,11 +330,11 @@
                exitstatus = 0;
                break;
        case NNOT:
-               evaltree(n->nnot.com, (sflags & EV_MORE) | EV_TESTED);
+               evaltree(n->nnot.com, EV_TESTED);
                exitstatus = !exitstatus;
                break;
        case NDNOT:
-               evaltree(n->nnot.com, (sflags & EV_MORE) | EV_TESTED);
+               evaltree(n->nnot.com, EV_TESTED);
                if (exitstatus != 0)
                        exitstatus = 1;
                break;
@@ -379,7 +378,7 @@
        CTRACE(DBG_EVAL,  ("\n"));
 
        for (;;) {
-               evaltree(n->nbinary.ch1, EV_TESTED | EV_MORE);
+               evaltree(n->nbinary.ch1, EV_TESTED);
                if (nflag)
                        break;
                if (evalskip) {
@@ -398,7 +397,7 @@
                        if (exitstatus == 0)
                                break;
                }
-               evaltree(n->nbinary.ch2, (flags & EV_TESTED) | EV_MORE);
+               evaltree(n->nbinary.ch2, flags & EV_TESTED);
                status = exitstatus;
                if (evalskip)
                        goto skipping;
@@ -431,11 +430,6 @@
 
        loopnest++;
        for (sp = arglist.list ; sp ; sp = sp->next) {
-               int f = flags & (EV_TESTED | EV_MORE);
-
-               if (sp->next)
-                       f |= EV_MORE;
-
                if (xflag) {
                        out2str(expandstr(ps4val(), line_number));
                        out2str("for ");
@@ -447,7 +441,7 @@
                }
 
                setvar(n->nfor.var, sp->text, 0);
-               evaltree(n->nfor.body, f);
+               evaltree(n->nfor.body, flags & EV_TESTED);
                status = exitstatus;
                if (nflag)
                        break;
@@ -493,8 +487,7 @@
                                        else
                                                ncp = NULL;
                                        line_number = cp->nclist.lineno;
-                                       evaltree(cp->nclist.body,
-                                           ncp ? (flags | EV_MORE) : flags);
+                                       evaltree(cp->nclist.body, flags);
                                        status = exitstatus;
                                        cp = ncp;
                                }
@@ -965,8 +958,6 @@
                INTOFF;
                jp = makejob(cmd, 1);
                mode = cmd->ncmd.backgnd;
-               if (mode)
-                       flags &= ~EV_MORE;
                if (flags & EV_BACKCMD) {
                        mode = FORK_NOJOB;
                        if (sh_pipe(pip) < 0)
@@ -1068,6 +1059,7 @@
        case CMDFUNCTION:
                VXTRACE(DBG_EVAL, ("Shell function:  "), trargs(argv));
                redirect(cmd->ncmd.redirect, flags & EV_MORE ? REDIR_PUSH : 0);
+               redirect(cmd->ncmd.redirect, REDIR_PUSH);
                saveparam = shellparam;
                shellparam.malloc = 0;
                shellparam.reset = 1;
@@ -1126,8 +1118,7 @@
                freeparam(&shellparam);
                shellparam = saveparam;
                handler = savehandler;
-               if (flags & EV_MORE)
-                       popredir();
+               popredir();
                INTON;
                if (evalskip == SKIPFUNC) {
                        evalskip = SKIPNONE;
diff -r 828916efc094 -r 04a4ffae01c3 bin/sh/eval.h
--- a/bin/sh/eval.h     Sat Aug 25 11:45:40 2018 +0000
+++ b/bin/sh/eval.h     Sat Aug 25 14:22:49 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eval.h,v 1.19 2016/05/09 21:03:10 kre Exp $    */
+/*     $NetBSD: eval.h,v 1.19.8.1 2018/08/25 14:22:49 martin Exp $     */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -76,4 +76,3 @@
 #define EV_EXIT                0x01    /* exit after evaluating tree */
 #define EV_TESTED      0x02    /* exit status is checked; ignore -e flag */
 #define EV_BACKCMD     0x04    /* command executing within back quotes */
-#define EV_MORE                0x08    /* more commands in this sub-shell */
diff -r 828916efc094 -r 04a4ffae01c3 bin/sh/main.c
--- a/bin/sh/main.c     Sat Aug 25 11:45:40 2018 +0000
+++ b/bin/sh/main.c     Sat Aug 25 14:22:49 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.70.2.1 2017/07/23 14:58:14 snj Exp $        */
+/*     $NetBSD: main.c,v 1.70.2.2 2018/08/25 14:22:49 martin Exp $     */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.7 (Berkeley) 7/19/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.70.2.1 2017/07/23 14:58:14 snj Exp $");
+__RCSID("$NetBSD: main.c,v 1.70.2.2 2018/08/25 14:22:49 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -292,7 +292,7 @@
                } else if (n != NULL && nflag == 0) {
                        job_warning = (job_warning == 2) ? 1 : 0;
                        numeof = 0;
-                       evaltree(n, EV_MORE);
+                       evaltree(n, 0);
                }
                popstackmark(&smark);
                setstackmark(&smark);



Home | Main Index | Thread Index | Old Index