Roman Rakus e73230
			     BASH PATCH REPORT
Roman Rakus e73230
			     =================
Roman Rakus e73230
Roman Rakus e73230
Bash-Release:	4.0
Roman Rakus e73230
Patch-ID:	bash40-016
Roman Rakus e73230
Roman Rakus e73230
Bug-Reported-by:	Brian J. Murrell" <brian@interlinx.bc.ca>
Roman Rakus e73230
Bug-Reference-ID:	<1237564627.7666.12.camel@pc.interlinx.bc.ca>
Roman Rakus e73230
Bug-Reference-URL:http://lists.gnu.org/archive/html/bug-bash/2009-03/msg00160.html
Roman Rakus e73230
Roman Rakus e73230
Bug-Description:
Roman Rakus e73230
Roman Rakus e73230
There are several problems with the handling of $LINENO in an ERR trap.
Roman Rakus e73230
Roman Rakus e73230
Patch:
Roman Rakus e73230
Roman Rakus e73230
*** ../bash-4.0-patched/trap.c	2009-01-16 17:07:53.000000000 -0500
Roman Rakus e73230
--- trap.c	2009-03-20 21:37:00.000000000 -0400
Roman Rakus e73230
***************
Roman Rakus e73230
*** 756,760 ****
Roman Rakus e73230
  
Roman Rakus e73230
        flags = SEVAL_NONINT|SEVAL_NOHIST;
Roman Rakus e73230
!       if (sig != DEBUG_TRAP && sig != RETURN_TRAP)
Roman Rakus e73230
  	flags |= SEVAL_RESETLINE;
Roman Rakus e73230
        if (function_code == 0)
Roman Rakus e73230
--- 756,760 ----
Roman Rakus e73230
  
Roman Rakus e73230
        flags = SEVAL_NONINT|SEVAL_NOHIST;
Roman Rakus e73230
!       if (sig != DEBUG_TRAP && sig != RETURN_TRAP && sig != ERROR_TRAP)
Roman Rakus e73230
  	flags |= SEVAL_RESETLINE;
Roman Rakus e73230
        if (function_code == 0)
Roman Rakus e73230
*** ../bash-4.0-patched/execute_cmd.c	2009-02-13 16:41:41.000000000 -0500
Roman Rakus e73230
--- execute_cmd.c	2009-03-21 14:16:11.000000000 -0400
Roman Rakus e73230
***************
Roman Rakus e73230
*** 569,572 ****
Roman Rakus e73230
--- 569,573 ----
Roman Rakus e73230
        /* Fork a subshell, turn off the subshell bit, turn off job
Roman Rakus e73230
  	 control and call execute_command () on the command again. */
Roman Rakus e73230
+       line_number_for_err_trap = line_number;
Roman Rakus e73230
        paren_pid = make_child (savestring (make_command_string (command)),
Roman Rakus e73230
  			      asynchronous);
Roman Rakus e73230
***************
Roman Rakus e73230
*** 611,615 ****
Roman Rakus e73230
--- 612,619 ----
Roman Rakus e73230
  		{
Roman Rakus e73230
  		  last_command_exit_value = exec_result;
Roman Rakus e73230
+ 		  save_line_number = line_number;
Roman Rakus e73230
+ 		  line_number = line_number_for_err_trap;
Roman Rakus e73230
  		  run_error_trap ();
Roman Rakus e73230
+ 		  line_number = save_line_number;
Roman Rakus e73230
  		}
Roman Rakus e73230
  
Roman Rakus e73230
***************
Roman Rakus e73230
*** 767,771 ****
Roman Rakus e73230
--- 771,777 ----
Roman Rakus e73230
  	{
Roman Rakus e73230
  	  last_command_exit_value = exec_result;
Roman Rakus e73230
+ 	  line_number = line_number_for_err_trap;
Roman Rakus e73230
  	  run_error_trap ();
Roman Rakus e73230
+ 	  line_number = save_line_number;
Roman Rakus e73230
  	}
Roman Rakus e73230
  
Roman Rakus e73230
***************
Roman Rakus e73230
*** 2106,2109 ****
Roman Rakus e73230
--- 2112,2116 ----
Roman Rakus e73230
    COMMAND *tc, *second;
Roman Rakus e73230
    int ignore_return, exec_result, was_error_trap, invert;
Roman Rakus e73230
+   volatile int save_line_number;
Roman Rakus e73230
  
Roman Rakus e73230
    ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0;
Roman Rakus e73230
***************
Roman Rakus e73230
*** 2175,2178 ****
Roman Rakus e73230
--- 2182,2186 ----
Roman Rakus e73230
        ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0;
Roman Rakus e73230
  
Roman Rakus e73230
+       line_number_for_err_trap = line_number;
Roman Rakus e73230
        exec_result = execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close);
Roman Rakus e73230
  
Roman Rakus e73230
***************
Roman Rakus e73230
*** 2180,2184 ****
Roman Rakus e73230
--- 2188,2195 ----
Roman Rakus e73230
  	{
Roman Rakus e73230
  	  last_command_exit_value = exec_result;
Roman Rakus e73230
+ 	  save_line_number = line_number;
Roman Rakus e73230
+ 	  line_number = line_number_for_err_trap;
Roman Rakus e73230
  	  run_error_trap ();
Roman Rakus e73230
+ 	  line_number = save_line_number;
Roman Rakus e73230
  	}
Roman Rakus e73230
  
Roman Rakus e73230
*** ../bash-4.0/patchlevel.h	2009-01-04 14:32:40.000000000 -0500
Roman Rakus e73230
--- patchlevel.h	2009-02-22 16:11:31.000000000 -0500
Roman Rakus e73230
***************
Roman Rakus e73230
*** 26,30 ****
Roman Rakus e73230
     looks for to find the patch level (for the sccs version string). */
Roman Rakus e73230
  
Roman Rakus e73230
! #define PATCHLEVEL 15
Roman Rakus e73230
  
Roman Rakus e73230
  #endif /* _PATCHLEVEL_H_ */
Roman Rakus e73230
--- 26,30 ----
Roman Rakus e73230
     looks for to find the patch level (for the sccs version string). */
Roman Rakus e73230
  
Roman Rakus e73230
! #define PATCHLEVEL 16
Roman Rakus e73230
  
Roman Rakus e73230
  #endif /* _PATCHLEVEL_H_ */