From 68097929869a3a3e511ac2e2c3d9dc3730652286 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 11 Aug 2009 20:48:15 +1000 Subject: [EVAL] Pass EV_TESTED into evalcmd This patch fixes the case where the eval command is used with set -e and as part of a construct that should not cause the shell to abort, e.g., as part of the condition of an if statement. This is achieved by propagating the EV_TESTED flag into the evalstring function through evalcmd. As this alters the prototype of evalcmd it is now invoked explicitly by evalbltin. The built-in infrastructure has been changed to accomodate this special case. In order to ensure that the EXIT trap is properly executed this patch clears evalskip in exitshell. This wasn't needed before because of the broken way evalstring worked where it always clears evalskip when called by minusc. Signed-off-by: Herbert Xu --- src/trap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/trap.c') diff --git a/src/trap.c b/src/trap.c index 5b8b046..16703b3 100644 --- a/src/trap.c +++ b/src/trap.c @@ -310,7 +310,7 @@ dotrap(void) p = trap[i + 1]; if (!p) continue; - evalstring(p, SKIPEVAL); + evalstring(p, 0); exitstatus = savestatus; if (evalskip) return evalskip; @@ -365,6 +365,7 @@ exitshell(void) handler = &loc; if ((p = trap[0])) { trap[0] = NULL; + evalskip = 0; evalstring(p, 0); } out: -- cgit 1.4.1