🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #852

Bash 1.04 patch: function return -- IMPORTANT

#852
From: Chip Salzenberg
Date: Mon, 22 Jan 1990 18:48
26 lines
1444 bytes
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;
  		    }
Technical Details
Message-ID: <m0gq95H-0001ZUC@ateng.ateng.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!bu.edu!bu-cs!snorkelwacker!tut.cis.ohio-state.edu!ateng.ateng.com!chip

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <m0gq95H-0001ZUC@ateng.ateng.com>
Date: 22 Jan 90 18:48:11 GMT
Sender: pollack@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 26