klibc-bot for Herbert Xu
2020-Mar-28 21:49 UTC
[klibc] [klibc:update-dash] dash: mkinit: Split reset into exitreset and reset
Commit-ID: 7f799aacc75667708bafe8f4411891ec053d7d65 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=7f799aacc75667708bafe8f4411891ec053d7d65 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Sat, 19 May 2018 02:39:40 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:55 +0000 [klibc] dash: mkinit: Split reset into exitreset and reset [ dash commit 983085923ae1d45196868b48f576b1a19e03e72b ] 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 at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/eval.c | 2 +- usr/dash/expand.c | 2 +- usr/dash/init.h | 2 +- usr/dash/main.c | 4 +++- usr/dash/mkinit.c | 8 ++++++++ usr/dash/redir.c | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index 13e690e7..ff27ba9c 100644 --- a/usr/dash/eval.c +++ b/usr/dash/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/usr/dash/expand.c b/usr/dash/expand.c index 59a202cb..6ea0562f 100644 --- a/usr/dash/expand.c +++ b/usr/dash/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/usr/dash/init.h b/usr/dash/init.h index e026e868..49791a07 100644 --- a/usr/dash/init.h +++ b/usr/dash/init.h @@ -35,5 +35,5 @@ */ void init(void); +void exitreset(void); void reset(void); -void initshellproc(void); diff --git a/usr/dash/main.c b/usr/dash/main.c index 9f037173..8b351189 100644 --- a/usr/dash/main.c +++ b/usr/dash/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/usr/dash/mkinit.c b/usr/dash/mkinit.c index 9714bee0..5bca9ee8 100644 --- a/usr/dash/mkinit.c +++ b/usr/dash/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/usr/dash/redir.c b/usr/dash/redir.c index 71b0f774..e67cc0ab 100644 --- a/usr/dash/redir.c +++ b/usr/dash/redir.c @@ -374,7 +374,7 @@ popredir(int drop) INCLUDE "redir.h" -RESET { +EXITRESET { /* * Discard all saved file descriptors. */
Apparently Analagous Threads
- [klibc:update-dash] dash: eval: Only restore exit status on exit/return
- [PATCH] ash not make -j safe, make spotless updates
- [klibc:update-dash] [BUILTIN] Exit without arguments in a trap should use status outside traps
- [klibc:update-dash] dash: [BUILTIN] Exit without arguments in a trap should use status outside traps
- [klibc:update-dash] input: Move all input state into parsefile