aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 0de81b325..02b21510e 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5558,6 +5558,28 @@ redirect(union node *redir, int flags)
preverrout_fd = copied_fd2;
}
+static int
+redirectsafe(union node *redir, int flags)
+{
+ int err;
+ volatile int saveint;
+ struct jmploc *volatile savehandler = exception_handler;
+ struct jmploc jmploc;
+
+ SAVE_INT(saveint);
+ /* "echo 9>/dev/null; echo >&9; echo result: $?" - result should be 1, not 2! */
+ err = setjmp(jmploc.loc); // huh?? was = setjmp(jmploc.loc) * 2;
+ if (!err) {
+ exception_handler = &jmploc;
+ redirect(redir, flags);
+ }
+ exception_handler = savehandler;
+ if (err && exception_type != EXERROR)
+ longjmp(exception_handler->loc, 1);
+ RESTORE_INT(saveint);
+ return err;
+}
+
/*
* Undo the effects of the last redirection.
*/
@@ -5593,32 +5615,6 @@ popredir(int drop, int restore)
INT_ON;
}
-/*
- * Undo all redirections. Called on error or interrupt.
- */
-
-static int
-redirectsafe(union node *redir, int flags)
-{
- int err;
- volatile int saveint;
- struct jmploc *volatile savehandler = exception_handler;
- struct jmploc jmploc;
-
- SAVE_INT(saveint);
- /* "echo 9>/dev/null; echo >&9; echo result: $?" - result should be 1, not 2! */
- err = setjmp(jmploc.loc); // huh?? was = setjmp(jmploc.loc) * 2;
- if (!err) {
- exception_handler = &jmploc;
- redirect(redir, flags);
- }
- exception_handler = savehandler;
- if (err && exception_type != EXERROR)
- longjmp(exception_handler->loc, 1);
- RESTORE_INT(saveint);
- return err;
-}
-
/* ============ Routines to expand arguments to commands
*