/*
* This routine is called when an error or an interrupt occurs in an
- * interactive shell and control is returned to the main command loop.
- * (In dash, this function is auto-generated by build machinery).
+ * interactive shell and control is returned to the main command loop
+ * but prior to exitshell.
*/
static void
-reset(void)
+exitreset(void)
{
/* from eval.c: */
evalskip = 0;
/* from expand.c: */
ifsfree();
+ /* from redir.c: */
+ unwindredir(NULL);
+}
+
+/*
+ * This routine is called when an error or an interrupt occurs in an
+ * interactive shell and control is returned to the main command loop.
+ * (In dash, this function is auto-generated by build machinery).
+ */
+static void
+reset(void)
+{
/* from input.c: */
g_parsefile->left_in_buffer = 0;
g_parsefile->left_in_line = 0; /* clear input buffer */
popallfiles();
- /* from redir.c: */
- unwindredir(NULL);
-
/* from var.c: */
unwindlocalvars(NULL);
}
smallint e;
smallint s;
- reset();
+ exitreset();
e = exception_type;
s = state;
if (e == EXEXIT || s == 0 || iflag == 0 || shlvl) {
exitshell();
}
+
+ reset();
+
if (e == EXINT) {
newline_and_flush(stderr);
}