From 983085923ae1d45196868b48f576b1a19e03e72b Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Sat, 19 May 2018 02:39:40 +0800 Subject: mkinit: Split reset into exitreset and reset 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 --- src/eval.c | 2 +- src/expand.c | 2 +- src/init.h | 2 +- src/main.c | 4 +++- src/mkinit.c | 8 ++++++++ src/redir.c | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/eval.c b/src/eval.c index 39c4e41..1b803db 100644 --- a/src/eval.c +++ b/src/eval.c @@ -112,7 +112,7 @@ STATIC const struct builtincmd bltin = { #ifdef mkinit INCLUDE "eval.h" -RESET { +EXITRESET { evalskip = 0; loopnest = 0; if (savestatus >= 0) { diff --git a/src/expand.c b/src/expand.c index 7ed259a..45e9b79 100644 --- a/src/expand.c +++ b/src/expand.c @@ -1780,7 +1780,7 @@ varunset(const char *end, const char *var, const char *umsg, int varflags) INCLUDE "expand.h" -RESET { +EXITRESET { ifsfree(); } diff --git a/src/init.h b/src/init.h index e026e86..49791a0 100644 --- a/src/init.h +++ b/src/init.h @@ -35,5 +35,5 @@ */ void init(void); +void exitreset(void); void reset(void); -void initshellproc(void); diff --git a/src/main.c b/src/main.c index 9f03717..8b35118 100644 --- a/src/main.c +++ b/src/main.c @@ -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")) diff --git a/src/mkinit.c b/src/mkinit.c index 9714bee..5bca9ee 100644 --- a/src/mkinit.c +++ b/src/mkinit.c @@ -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} }; diff --git a/src/redir.c b/src/redir.c index 71b0f77..e67cc0a 100644 --- a/src/redir.c +++ b/src/redir.c @@ -374,7 +374,7 @@ popredir(int drop) INCLUDE "redir.h" -RESET { +EXITRESET { /* * Discard all saved file descriptors. */ -- cgit 1.4.1 n>Update imbox to 1.4June McEnroe 2021-02-09Update catgirl to 1.6June McEnroe 2021-02-08Update catsit to 1.2June McEnroe 2021-02-08Update pounce to 2.3June McEnroe 2021-02-04Update cgit-causal-agency to 8e4c63cJune McEnroe 2021-01-20Update cgit-causal-agency to 8a10aa5June McEnroe 2021-01-17Update cgit-causal-agencyJune McEnroe 2021-01-17Update scooper to 1.1June McEnroe 2021-01-17Update catgirl to 1.5 (BONUS WEBISODE)June McEnroe 2021-01-15Update litterbox to 1.7June McEnroe 2021-01-15Update pounce to 2.2June McEnroe 2021-01-15Update catgirl to 1.4June McEnroe 2020-12-28Replace cgit-patched with cgit-causal-agencyJune McEnroe 2020-12-18Add notemap portJune McEnroe 2020-12-15Update libretls to 3.3.1June McEnroe 2020-12-15Update catsit to 1.1June McEnroe 2020-12-15Update pounce to 2.1p1June McEnroe 2020-12-15Add imbox portJune McEnroe 2020-11-24Update pounce to 2.1June McEnroe 2020-11-24Update libretls to 3.3.0June McEnroe 2020-11-17Update catgirl to 1.3June McEnroe 2020-11-17Update libretls to 3.2.2June McEnroe 2020-09-29Update libretls to 3.2.1June McEnroe 2020-09-10Update catgirl to 1.2June McEnroe 2020-09-09Add pounce-palaver portJune McEnroe 2020-09-09Update pounce to 2.0June McEnroe 2020-09-09Update litterbox to 1.6June McEnroe 2020-08-23Add scooper portJune McEnroe 2020-08-23Add catsit portJune McEnroe 2020-08-13Update pounce to 1.4p2June McEnroe 2020-08-11Update pounce to 1.4p1June McEnroe 2020-08-10Add litterbox portJune McEnroe 2020-08-10Add missing USES=pkgconfig to pounceJune McEnroe