diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-12-08 20:13:04 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-12-08 20:13:04 -0500 |
commit | dfc21851b525db2b6778d20279c589e023e68e5d (patch) | |
tree | 8c5920e69a9392b53dc1a3aed79a011aea6c7eff /execute_cmd.c | |
parent | 0527c9035cae5c3fa84393a8eb48ec1582120c7e (diff) | |
download | bash-dfc21851b525db2b6778d20279c589e023e68e5d.tar.gz |
commit bash-20090723 snapshot
Diffstat (limited to 'execute_cmd.c')
-rw-r--r-- | execute_cmd.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/execute_cmd.c b/execute_cmd.c index 204dd348..95866ddc 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -3814,25 +3814,35 @@ execute_builtin (builtin, words, flags, subshell) { int old_e_flag, result, eval_unwind; int isbltinenv; + char *error_trap; #if 0 /* XXX -- added 12/11 */ terminate_immediately++; #endif + error_trap = 0; old_e_flag = exit_immediately_on_error; /* The eval builtin calls parse_and_execute, which does not know about the setting of flags, and always calls the execution functions with flags that will exit the shell on an error if -e is set. If the eval builtin is being called, and we're supposed to ignore the exit - value of the command, we turn the -e flag off ourselves, then - restore it when the command completes. This is also a problem (as - below) for the command and source/. builtins. */ + value of the command, we turn the -e flag off ourselves and disable + the ERR trap, then restore them when the command completes. This is + also a problem (as below) for the command and source/. builtins. */ if (subshell == 0 && (flags & CMD_IGNORE_RETURN) && (builtin == eval_builtin || builtin == command_builtin || builtin == source_builtin)) { begin_unwind_frame ("eval_builtin"); unwind_protect_int (exit_immediately_on_error); + error_trap = TRAP_STRING (ERROR_TRAP); + if (error_trap) + { + error_trap = savestring (error_trap); + add_unwind_protect (xfree, error_trap); + add_unwind_protect (set_error_trap, error_trap); + restore_default_signal (ERROR_TRAP); + } exit_immediately_on_error = 0; eval_unwind = 1; } @@ -3883,6 +3893,11 @@ execute_builtin (builtin, words, flags, subshell) if (eval_unwind) { exit_immediately_on_error += old_e_flag; + if (error_trap) + { + set_error_trap (error_trap); + xfree (error_trap); + } discard_unwind_frame ("eval_builtin"); } |