Roman Rakus 2cb460
			     BASH PATCH REPORT
Roman Rakus 2cb460
			     =================
Roman Rakus 2cb460
Roman Rakus 2cb460
Bash-Release: 3.2
Roman Rakus 2cb460
Patch-ID: bash32-039
Roman Rakus 2cb460
Roman Rakus 2cb460
Bug-Reported-by:	rew@erebor.com
Roman Rakus 2cb460
Bug-Reference-ID:	<20070119065603.546D011E9C@kansas.erebor.com>
Roman Rakus 2cb460
Bug-Reference-URL:	
Roman Rakus 2cb460
Roman Rakus 2cb460
Bug-Description:
Roman Rakus 2cb460
Roman Rakus 2cb460
Bash-3.2 changed the behavior of the [[ command's `=~' operator when the
Roman Rakus 2cb460
right-hand side was quoted:  it matched the quoted portions as strings.
Roman Rakus 2cb460
This patch introduces a new shell option: compat31.  When enabled, it
Roman Rakus 2cb460
restores the bash-3.1 behavior with respect to evaluating quoted arguments
Roman Rakus 2cb460
to the =~ operator.
Roman Rakus 2cb460
Roman Rakus 2cb460
Patch:
Roman Rakus 2cb460
Roman Rakus 2cb460
*** ../bash-3.2-patched/execute_cmd.c	2007-12-14 21:12:39.000000000 -0500
Roman Rakus 2cb460
--- execute_cmd.c	2008-02-22 21:20:40.000000000 -0500
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 2547,2551 ****
Roman Rakus 2cb460
        if (arg1 == 0)
Roman Rakus 2cb460
  	arg1 = nullstr;
Roman Rakus 2cb460
!       arg2 = cond_expand_word (cond->right->op, rmatch ? 2 : (patmatch ? 1 : 0));
Roman Rakus 2cb460
        if (arg2 == 0)
Roman Rakus 2cb460
  	arg2 = nullstr;
Roman Rakus 2cb460
--- 2552,2557 ----
Roman Rakus 2cb460
        if (arg1 == 0)
Roman Rakus 2cb460
  	arg1 = nullstr;
Roman Rakus 2cb460
!       arg2 = cond_expand_word (cond->right->op,
Roman Rakus 2cb460
! 			       (rmatch && shell_compatibility_level > 31) ? 2 : (patmatch ? 1 : 0));
Roman Rakus 2cb460
        if (arg2 == 0)
Roman Rakus 2cb460
  	arg2 = nullstr;
Roman Rakus 2cb460
*** ../bash-3.2-patched/shell.h	2003-06-01 15:04:36.000000000 -0400
Roman Rakus 2cb460
--- shell.h	2008-02-22 21:16:48.000000000 -0500
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 90,93 ****
Roman Rakus 2cb460
--- 90,94 ----
Roman Rakus 2cb460
  extern int interactive, interactive_shell;
Roman Rakus 2cb460
  extern int startup_state;
Roman Rakus 2cb460
+ extern int shell_compatibility_level;
Roman Rakus 2cb460
  
Roman Rakus 2cb460
  /* Structure to pass around that holds a bitmap of file descriptors
Roman Rakus 2cb460
*** ../bash-3.2-patched/version.c	2007-12-14 21:12:29.000000000 -0500
Roman Rakus 2cb460
--- version.c	2008-04-10 08:22:22.000000000 -0400
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 44,47 ****
Roman Rakus 2cb460
--- 44,50 ----
Roman Rakus 2cb460
  const char *sccs_version = SCCSVERSION;
Roman Rakus 2cb460
  
Roman Rakus 2cb460
+ /* If == 31, shell compatible with bash-3.1, == 32 with bash-3.2, and so on */
Roman Rakus 2cb460
+ int shell_compatibility_level = 32;
Roman Rakus 2cb460
+ 
Roman Rakus 2cb460
  /* Functions for getting, setting, and displaying the shell version. */
Roman Rakus 2cb460
  
Roman Rakus 2cb460
*** ../bash-3.2-patched/builtins/shopt.def	2005-02-19 17:25:03.000000000 -0500
Roman Rakus 2cb460
--- builtins/shopt.def	2008-04-10 08:13:32.000000000 -0400
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 102,105 ****
Roman Rakus 2cb460
--- 102,107 ----
Roman Rakus 2cb460
  static int set_shellopts_after_change __P((int));
Roman Rakus 2cb460
  
Roman Rakus 2cb460
+ static int set_compatibility_level __P((int));
Roman Rakus 2cb460
+ 
Roman Rakus 2cb460
  #if defined (RESTRICTED_SHELL)
Roman Rakus 2cb460
  static int set_restricted_shell __P((int));
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 107,110 ****
Roman Rakus 2cb460
--- 109,113 ----
Roman Rakus 2cb460
  
Roman Rakus 2cb460
  static int shopt_login_shell;
Roman Rakus 2cb460
+ static int shopt_compat31;
Roman Rakus 2cb460
  
Roman Rakus 2cb460
  typedef int shopt_set_func_t __P((int));
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 122,125 ****
Roman Rakus 2cb460
--- 125,129 ----
Roman Rakus 2cb460
    { "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
Roman Rakus 2cb460
  #endif
Roman Rakus 2cb460
+   { "compat31", &shopt_compat31, set_compatibility_level },
Roman Rakus 2cb460
    { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
Roman Rakus 2cb460
    { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 460,463 ****
Roman Rakus 2cb460
--- 464,479 ----
Roman Rakus 2cb460
  }
Roman Rakus 2cb460
  
Roman Rakus 2cb460
+ static int
Roman Rakus 2cb460
+ set_compatibility_level (mode)
Roman Rakus 2cb460
+      int mode;
Roman Rakus 2cb460
+ {
Roman Rakus 2cb460
+   /* Need to change logic here as we add more compatibility levels */
Roman Rakus 2cb460
+   if (shopt_compat31)
Roman Rakus 2cb460
+     shell_compatibility_level = 31;
Roman Rakus 2cb460
+   else
Roman Rakus 2cb460
+     shell_compatibility_level = 32;
Roman Rakus 2cb460
+   return 0;
Roman Rakus 2cb460
+ }
Roman Rakus 2cb460
+ 
Roman Rakus 2cb460
  #if defined (RESTRICTED_SHELL)
Roman Rakus 2cb460
  /* Don't allow the value of restricted_shell to be modified. */
Roman Rakus 2cb460
*** ../bash-3.2-patched/doc/bash.1	2006-09-28 10:26:05.000000000 -0400
Roman Rakus 2cb460
--- doc/bash.1	2008-04-25 12:32:49.000000000 -0400
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 7978,7981 ****
Roman Rakus 2cb460
--- 8200,8209 ----
Roman Rakus 2cb460
  easy re-editing of multi-line commands.
Roman Rakus 2cb460
  .TP 8
Roman Rakus 2cb460
+ .B compat31
Roman Rakus 2cb460
+ If set,
Roman Rakus 2cb460
+ .B bash
Roman Rakus 2cb460
+ changes its behavior to that of version 3.1 with respect to quoted
Roman Rakus 2cb460
+ arguments to the conditional command's =~ operator.
Roman Rakus 2cb460
+ .TP 8
Roman Rakus 2cb460
  .B dotglob
Roman Rakus 2cb460
  If set, 
Roman Rakus 2cb460
*** ../bash-20080214/doc/bashref.texi	2008-02-08 21:28:35.000000000 -0500
Roman Rakus 2cb460
--- doc/bashref.texi	2008-02-22 21:44:51.000000000 -0500
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 4053,4056 ****
Roman Rakus 2cb460
--- 4061,4069 ----
Roman Rakus 2cb460
  easy re-editing of multi-line commands.
Roman Rakus 2cb460
  
Roman Rakus 2cb460
+ @item compat31
Roman Rakus 2cb460
+ If set, Bash
Roman Rakus 2cb460
+ changes its behavior to that of version 3.1 with respect to quoted
Roman Rakus 2cb460
+ arguments to the conditional command's =~ operator.
Roman Rakus 2cb460
+ 
Roman Rakus 2cb460
  @item dotglob
Roman Rakus 2cb460
  If set, Bash includes filenames beginning with a `.' in
Roman Rakus 2cb460
*** ../bash-3.2-patched/tests/shopt.right	2005-02-19 17:46:09.000000000 -0500
Roman Rakus 2cb460
--- tests/shopt.right	2008-04-28 09:13:07.000000000 -0400
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 7,10 ****
Roman Rakus 2cb460
--- 7,11 ----
Roman Rakus 2cb460
  shopt -u checkwinsize
Roman Rakus 2cb460
  shopt -s cmdhist
Roman Rakus 2cb460
+ shopt -u compat31
Roman Rakus 2cb460
  shopt -u dotglob
Roman Rakus 2cb460
  shopt -u execfail
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 54,57 ****
Roman Rakus 2cb460
--- 55,59 ----
Roman Rakus 2cb460
  shopt -u checkhash
Roman Rakus 2cb460
  shopt -u checkwinsize
Roman Rakus 2cb460
+ shopt -u compat31
Roman Rakus 2cb460
  shopt -u dotglob
Roman Rakus 2cb460
  shopt -u execfail
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 78,81 ****
Roman Rakus 2cb460
--- 80,84 ----
Roman Rakus 2cb460
  checkhash      	off
Roman Rakus 2cb460
  checkwinsize   	off
Roman Rakus 2cb460
+ compat31       	off
Roman Rakus 2cb460
  dotglob        	off
Roman Rakus 2cb460
  execfail       	off
Roman Rakus 2cb460
Roman Rakus 2cb460
*** ../bash-3.2/patchlevel.h	Thu Apr 13 08:31:04 2006
Roman Rakus 2cb460
--- patchlevel.h	Mon Oct 16 14:22:54 2006
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 26,30 ****
Roman Rakus 2cb460
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 2cb460
  
Roman Rakus 2cb460
! #define PATCHLEVEL 38
Roman Rakus 2cb460
  
Roman Rakus 2cb460
  #endif /* _PATCHLEVEL_H_ */
Roman Rakus 2cb460
--- 26,30 ----
Roman Rakus 2cb460
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 2cb460
  
Roman Rakus 2cb460
! #define PATCHLEVEL 39
Roman Rakus 2cb460
  
Roman Rakus 2cb460
  #endif /* _PATCHLEVEL_H_ */