change behaviour of argument-less exit in traps to match SUSv4; Debian #599484 (original patch from Jonathan Nieder, thanks!) in a variant that appears to handle nested traps well

This commit is contained in:
tg
2010-11-01 17:29:05 +00:00
parent e57379aab7
commit 27dce9168a
5 changed files with 59 additions and 23 deletions

10
main.c
View File

@@ -33,7 +33,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.172 2010/09/14 21:26:14 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.173 2010/11/01 17:29:04 tg Exp $");
extern char **environ;
@@ -672,10 +672,14 @@ unwind(int i)
/* ordering for EXIT vs ERR is a bit odd (this is what AT&T ksh does) */
if (i == LEXIT || (Flag(FERREXIT) && (i == LERROR || i == LINTR) &&
sigtraps[SIGEXIT_].trap)) {
runtrap(&sigtraps[SIGEXIT_]);
++trap_nested;
runtrap(&sigtraps[SIGEXIT_], trap_nested == 1);
--trap_nested;
i = LLEAVE;
} else if (Flag(FERREXIT) && (i == LERROR || i == LINTR)) {
runtrap(&sigtraps[SIGERR_]);
++trap_nested;
runtrap(&sigtraps[SIGERR_], trap_nested == 1);
--trap_nested;
i = LLEAVE;
}
while (1) {