summary refs log tree commit diff
path: root/src/eval.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2014-10-02 21:07:55 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2014-10-02 21:07:55 +0800
commitb4ce4120f87d89476b2d6ab31df43900d2f5ce89 (patch)
treef4f0e892d1987f9119be2892fee0fa3749523c10 /src/eval.c
parent[TRAP] Make sure evalskip is zero before running traps (diff)
downloaddash-b4ce4120f87d89476b2d6ab31df43900d2f5ce89.tar.gz
dash-b4ce4120f87d89476b2d6ab31df43900d2f5ce89.zip
[ERROR] Set exitstatus in onint
Currently the exit status when we receive SIGINT is set in evalcommand
which means that it doesn't always get set.  For example, if you press
CTRL-C at the prompt of an interactive dash, the exit status is not
set to 130 as it is in many other Bourne shells.

This patch fixes this by moving the setting of the exit status into
onint which also simplifies evalcommand.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--src/eval.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/eval.c b/src/eval.c
index 7f06931..0708bf5 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -853,21 +853,15 @@ bail:
 				listsetvar(varlist.list, VEXPORT);
 		}
 		if (evalbltin(cmdentry.u.cmd, argc, argv, flags)) {
-			int status;
-			int i;
-
-			i = exception;
-			if (i == EXEXIT)
-				goto raise;
-
-			status = (i == EXINT) ? SIGINT + 128 : 2;
-			exitstatus = status;
-
-			if (i == EXINT || spclbltin > 0) {
-raise:
-				longjmp(handler->loc, 1);
+			if (exception == EXERROR) {
+				exitstatus = 2;
+				if (spclbltin <= 0) {
+					FORCEINTON;
+					break;
+				}
 			}
-			FORCEINTON;
+raise:
+			longjmp(handler->loc, 1);
 		}
 		break;