Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh PR bin/48875
details: https://anonhg.NetBSD.org/src/rev/f7146ab571df
branches: trunk
changeset: 365520:f7146ab571df
user: kre <kre%NetBSD.org@localhost>
date: Sun Aug 19 11:16:13 2018 +0000
description:
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 | 44 +++++++++++++++++---------------------------
bin/sh/eval.h | 3 +--
bin/sh/main.c | 6 +++---
3 files changed, 21 insertions(+), 32 deletions(-)
diffs (201 lines):
diff -r 4e6aedb4130c -r f7146ab571df bin/sh/eval.c
--- a/bin/sh/eval.c Sun Aug 19 10:47:45 2018 +0000
+++ b/bin/sh/eval.c Sun Aug 19 11:16:13 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: eval.c,v 1.157 2018/08/14 13:36:42 kre Exp $ */
+/* $NetBSD: eval.c,v 1.158 2018/08/19 11:16:13 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.157 2018/08/14 13:36:42 kre Exp $");
+__RCSID("$NetBSD: eval.c,v 1.158 2018/08/19 11:16:13 kre 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) {
outxstr(expandstr(ps4val(), line_number));
outxstr("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;
}
@@ -966,8 +959,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)
@@ -1069,7 +1060,7 @@
case CMDFUNCTION:
VXTRACE(DBG_EVAL, ("Shell function%s: ",vforked?" VF":""),
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;
@@ -1128,8 +1119,7 @@
freeparam(&shellparam);
shellparam = saveparam;
handler = savehandler;
- if (flags & EV_MORE)
- popredir();
+ popredir();
INTON;
if (evalskip == SKIPFUNC) {
evalskip = SKIPNONE;
diff -r 4e6aedb4130c -r f7146ab571df bin/sh/eval.h
--- a/bin/sh/eval.h Sun Aug 19 10:47:45 2018 +0000
+++ b/bin/sh/eval.h Sun Aug 19 11:16:13 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: eval.h,v 1.20 2018/07/25 14:42:50 kre Exp $ */
+/* $NetBSD: eval.h,v 1.21 2018/08/19 11:16:13 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -78,4 +78,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 4e6aedb4130c -r f7146ab571df bin/sh/main.c
--- a/bin/sh/main.c Sun Aug 19 10:47:45 2018 +0000
+++ b/bin/sh/main.c Sun Aug 19 11:16:13 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.73 2018/01/23 22:12:52 sevan Exp $ */
+/* $NetBSD: main.c,v 1.74 2018/08/19 11:16:13 kre 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.73 2018/01/23 22:12:52 sevan Exp $");
+__RCSID("$NetBSD: main.c,v 1.74 2018/08/19 11:16:13 kre Exp $");
#endif
#endif /* not lint */
@@ -291,7 +291,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