From 11b073410867756f8fd04cc3b302ea8deef83433 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 24 Sep 2001 10:12:51 +0000 Subject: * Src/builtin.c, Src/exec.c: Unwind function calls before exiting shell from exit command to allow EXIT traps to run. --- Src/exec.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Src/exec.c') diff --git a/Src/exec.c b/Src/exec.c index 17ba376dd..c55494b96 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3429,6 +3429,22 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) if (noreturnval) lastval = oldlastval; popheap(); + + if (exit_pending) { + if (locallevel) { + /* Still functions to return: force them to do so. */ + retflag = 1; + breaks = loops; + } else { + /* + * All functions finished: time to exit the shell. + * We already did the `stopmsg' test when the + * exit command was handled. + */ + stopmsg = 1; + zexit(exit_pending >> 1, 0); + } + } } /* This finally executes a shell function and any function wrappers * -- cgit v1.2.3