@@ -112,7 +112,7 @@ STATIC const struct builtincmd bltin = {
#ifdef mkinit
INCLUDE "eval.h"
-RESET {
+EXITRESET {
evalskip = 0;
loopnest = 0;
if (savestatus >= 0) {
@@ -1780,7 +1780,7 @@ varunset(const char *end, const char *var, const char *umsg, int varflags)
INCLUDE "expand.h"
-RESET {
+EXITRESET {
ifsfree();
}
@@ -35,5 +35,5 @@
*/
void init(void);
+void exitreset(void);
void reset(void);
-void initshellproc(void);
@@ -106,7 +106,7 @@ main(int argc, char **argv)
int e;
int s;
- reset();
+ exitreset();
e = exception;
@@ -114,6 +114,8 @@ main(int argc, char **argv)
if (e == EXEXIT || s == 0 || iflag == 0 || shlvl)
exitshell();
+ reset();
+
if (e == EXINT
#if ATTY
&& (! attyset() || equal(termval(), "emacs"))
@@ -106,6 +106,13 @@ char init[] = "\
* Initialization code.\n\
*/\n";
+char exitreset[] = "\
+/*\n\
+ * This routine is called when an error or an interrupt occurs in an\n\
+ * interactive shell and control is returned to the main command loop\n\
+ * but prior to exitshell. \n\
+ */\n";
+
char reset[] = "\
/*\n\
* This routine is called when an error or an interrupt occurs in an\n\
@@ -115,6 +122,7 @@ char reset[] = "\
struct event event[] = {
{"INIT", "init", init},
+ {"EXITRESET", "exitreset", exitreset},
{"RESET", "reset", reset},
{NULL, NULL}
};
@@ -374,7 +374,7 @@ popredir(int drop)
INCLUDE "redir.h"
-RESET {
+EXITRESET {
/*
* Discard all saved file descriptors.
*/
Previously reset was called after exitshell. This was changed so that it was called before exitshell because certain state needed to be reset in order for the EXIT trap to work. However, this caused issues because certain other states (such as local variables) should not be reset. This patch fixes this by creating a new function exitreset that is called prior to exitshell and moving reset back to its original location. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>