Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!bu.edu!bu-cs!snorkelwacker!tut.cis.ohio-state.edu!ateng.ateng.com!chip From: chip@ateng.ateng.com (Chip Salzenberg) Newsgroups: gnu.bash.bug Subject: Bash 1.04 patch: function return -- IMPORTANT Message-ID: Date: 22 Jan 90 18:48:11 GMT Sender: pollack@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 26 Bash 1.04 has a serious bug in the handling of the "return" statement in shell functions. Falling off the end of a shell function automatically cleans up local variables and redirection. The code obviously should do the same when the "return" statement is executed, but Bash 1.04, as distributed, does not do so. This patch fixes the bug. Index: execute_cmd.c *************** *** 741,747 **** remember_args (words->next, 1); result = execute_command (tc); - run_unwind_frame ("function_calling"); } return_catch_flag--; redirection_undo_list = saved_undo_list; } --- 741,749 ---- remember_args (words->next, 1); result = execute_command (tc); } + run_unwind_frame ("function_calling"); return_catch_flag--; + do_redirections (redirection_undo_list, 1, 0); + dispose_redirects (redirection_undo_list); redirection_undo_list = saved_undo_list; }