diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-12-03 13:40:27 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-12-03 13:40:27 -0500 |
commit | 54cdd75ae4b6d214e3a3575abe95caba3a3c04e6 (patch) | |
tree | 77a20c0866ed974daef2164b8ef4285d5fbb314e /execute_cmd.c~ | |
parent | eb2bb5621ff0d28462beb37de38aaccf324117f3 (diff) | |
download | bash-54cdd75ae4b6d214e3a3575abe95caba3a3c04e6.tar.gz |
commit bash-20041124 snapshot
Diffstat (limited to 'execute_cmd.c~')
-rw-r--r-- | execute_cmd.c~ | 64 |
1 files changed, 49 insertions, 15 deletions
diff --git a/execute_cmd.c~ b/execute_cmd.c~ index b434938c..64b940ed 100644 --- a/execute_cmd.c~ +++ b/execute_cmd.c~ @@ -1619,8 +1619,9 @@ execute_for_command (for_command) if (echo_command_at_execute) xtrace_print_for_command_head (for_command); - /* Save this command unless it's a trap command. */ - if (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0)) + /* Save this command unless it's a trap command and we're not running + a debug trap. */ + if (signal_in_progress (DEBUG_TRAP) == 0 && (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0))) { FREE (the_printed_command_except_trap); the_printed_command_except_trap = savestring (the_printed_command); @@ -1728,8 +1729,11 @@ eval_arith_for_expr (l, okp) command_string_index = 0; print_arith_command (new); - FREE (the_printed_command_except_trap); - the_printed_command_except_trap = savestring (the_printed_command); + if (signal_in_progress (DEBUG_TRAP) == 0) + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } r = run_debug_trap (); /* In debugging mode, if the DEBUG trap returns a non-zero status, we @@ -2036,8 +2040,11 @@ execute_select_command (select_command) if (echo_command_at_execute) xtrace_print_select_command_head (select_command); - FREE (the_printed_command_except_trap); - the_printed_command_except_trap = savestring (the_printed_command); + if (signal_in_progress (DEBUG_TRAP) == 0 && (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0))) + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } retval = run_debug_trap (); #if defined (DEBUGGER) @@ -2165,7 +2172,7 @@ execute_case_command (case_command) if (echo_command_at_execute) xtrace_print_case_command_head (case_command); - if (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0)) + if (signal_in_progress (DEBUG_TRAP == 0) && (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0))) { FREE (the_printed_command_except_trap); the_printed_command_except_trap = savestring (the_printed_command); @@ -2375,8 +2382,12 @@ execute_arith_command (arith_command) command_string_index = 0; print_arith_command (arith_command->exp); - FREE (the_printed_command_except_trap); - the_printed_command_except_trap = savestring (the_printed_command); + + if (signal_in_progress (DEBUG_TRAP) == 0) + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } /* Run the debug trap before each arithmetic command, but do it after we update the line number information and before we expand the various @@ -2532,8 +2543,12 @@ execute_cond_command (cond_command) command_string_index = 0; print_cond_command (cond_command); - FREE (the_printed_command_except_trap); - the_printed_command_except_trap = savestring (the_printed_command); + + if (signal_in_progress (DEBUG_TRAP) == 0) + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } /* Run the debug trap before each conditional command, but do it after we update the line number information. */ @@ -2686,7 +2701,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close) command_string_index = 0; print_simple_command (simple_command); - if (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0)) + if (signal_in_progress (DEBUG_TRAP) == 0 && (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0))) { FREE (the_printed_command_except_trap); the_printed_command_except_trap = the_printed_command ? savestring (the_printed_command) : (char *)0; @@ -3099,7 +3114,7 @@ execute_function (var, words, flags, fds_to_close, async, subshell) COMMAND *tc, *fc, *save_current; char *debug_trap, *error_trap, *return_trap; #if defined (ARRAY_VARS) - SHELL_VAR *funcname_v, *bash_source_v, *bash_lineno_v; + SHELL_VAR *funcname_v, *nfv, *bash_source_v, *bash_lineno_v; ARRAY *funcname_a, *bash_source_a, *bash_lineno_a; #endif FUNCTION_DEF *shell_fn; @@ -3225,7 +3240,15 @@ execute_function (var, words, flags, fds_to_close, async, subshell) return_val = setjmp (return_catch); if (return_val) - result = return_catch_value; + { + result = return_catch_value; +#if 0 + /* Run the RETURN trap in the function's context */ + save_current = currently_executing_command; + run_return_trap (); + currently_executing_command = save_current; +#endif + } else { /* Run the debug trap here so we can trap at the start of a function's @@ -3249,6 +3272,10 @@ execute_function (var, words, flags, fds_to_close, async, subshell) } #else result = execute_command_internal (fc, 0, NO_PIPE, NO_PIPE, fds_to_close); + + save_current = currently_executing_command; + run_return_trap (); + currently_executing_command = save_current; #endif showing_function_line = 0; } @@ -3262,9 +3289,16 @@ execute_function (var, words, flags, fds_to_close, async, subshell) funcnest--; #if defined (ARRAY_VARS) + /* These two variables cannot be unset, and cannot be affected by the + function. */ array_pop (bash_source_a); - array_pop (funcname_a); array_pop (bash_lineno_a); + + /* FUNCNAME can be unset, and so can potentially be changed by the + function. */ + GET_ARRAY_FROM_VAR ("FUNCNAME", nfv, funcname_a); + if (nfv == funcname_v) + array_pop (funcname_a); #endif if (variable_context == 0 || this_shell_function == 0) |