← Commit list

f415e21a7

Denys Vlasenko
Denys Vlasenko
2021-09-07
SUCCESS Duration: 153s

Subject

ash: eval: Do not cache value of eflag in evaltree

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash.c+7 -8
@@ -9336,8 +9336,7 @@ evaltree(union node *n, int flags)
case NCMD:
evalfn = evalcommand;
checkexit:
- if (!(flags & EV_TESTED))
- checkexit = ~0;
+ checkexit = ~flags & EV_TESTED;
goto calleval;
case NFOR:
evalfn = evalfor;
@@ -9359,7 +9358,6 @@ evaltree(union node *n, int flags)
case NAND:
case NOR:
case NSEMI: {
-
#if NAND + 1 != NOR
#error NAND + 1 != NOR
#endif
@@ -9387,8 +9385,7 @@ evaltree(union node *n, int flags)
if (!status) {
n = n->nif.ifpart;
goto evaln;
- }
- if (n->nif.elsepart) {
+ } else if (n->nif.elsepart) {
n = n->nif.elsepart;
goto evaln;
}
@@ -9410,7 +9407,7 @@ evaltree(union node *n, int flags)
*/
dotrap();
- if (checkexit & status) {
+ if (checkexit && status) {
if (trap[NTRAP_ERR] && !in_trap_ERR) {
int err;
struct jmploc *volatile savehandler = exception_handler;
@@ -9434,10 +9431,12 @@ evaltree(union node *n, int flags)
exitstatus = savestatus;
}
if (eflag)
- raise_exception(EXEND);
+ goto exexit;
}
- if (flags & EV_EXIT)
+ if (flags & EV_EXIT) {
+ exexit:
raise_exception(EXEND);
+ }
popstackmark(&smark);
TRACE(("leaving evaltree (no interrupts)\n"));
shell/ash_test/ash-misc/exitcode_trap7.right+2 -0
@@ -0,0 +1,2 @@
+Start
+Ok:0
shell/ash_test/ash-misc/exitcode_trap7.tests+7 -0
@@ -0,0 +1,7 @@
+$THIS_SH -c '
+cleanup() { set +e; false; }
+set -eu
+trap cleanup EXIT
+echo Start
+'
+echo Ok:$?