393b612
			     BASH PATCH REPORT
393b612
			     =================
393b612
393b612
Bash-Release: 3.2
393b612
Patch-ID: bash32-004
393b612
393b612
Bug-Reported-by:	Stuart Shelton <srcshelton@gmail.com>
393b612
Bug-Reference-ID:	<619141e40610261203y6cda5aa6i23cb24c7aeba996e@mail.gmail.com>
393b612
Bug-Reference-URL:	
393b612
393b612
Bug-Description:
393b612
393b612
A bug in the parameter pattern substitution implementation treated a pattern
393b612
whose first character was `/' (after expansion) as specifying global
393b612
replacement.
393b612
393b612
Patch:
393b612
393b612
*** ../bash-3.2/subst.c	Tue Sep 19 08:35:09 2006
393b612
--- subst.c	Thu Oct 26 09:17:50 2006
393b612
***************
393b612
*** 5707,5712 ****
393b612
--- 5707,5717 ----
393b612
    vtype &= ~VT_STARSUB;
393b612
  
393b612
    mflags = 0;
393b612
+   if (patsub && *patsub == '/')
393b612
+     {
393b612
+       mflags |= MATCH_GLOBREP;
393b612
+       patsub++;
393b612
+     }
393b612
  
393b612
    /* Malloc this because expand_string_if_necessary or one of the expansion
393b612
       functions in its call chain may free it on a substitution error. */
393b612
***************
393b612
*** 5741,5753 ****
393b612
      }
393b612
  
393b612
    /* ksh93 doesn't allow the match specifier to be a part of the expanded
393b612
!      pattern.  This is an extension. */
393b612
    p = pat;
393b612
!   if (pat && pat[0] == '/')
393b612
!     {
393b612
!       mflags |= MATCH_GLOBREP|MATCH_ANY;
393b612
!       p++;
393b612
!     }
393b612
    else if (pat && pat[0] == '#')
393b612
      {
393b612
        mflags |= MATCH_BEG;
393b612
--- 5746,5757 ----
393b612
      }
393b612
  
393b612
    /* ksh93 doesn't allow the match specifier to be a part of the expanded
393b612
!      pattern.  This is an extension.  Make sure we don't anchor the pattern
393b612
!      at the beginning or end of the string if we're doing global replacement,
393b612
!      though. */
393b612
    p = pat;
393b612
!   if (mflags & MATCH_GLOBREP)
393b612
!     mflags |= MATCH_ANY;
393b612
    else if (pat && pat[0] == '#')
393b612
      {
393b612
        mflags |= MATCH_BEG;
393b612
*** ../bash-3.2/tests/new-exp.right	Thu Aug 10 12:00:00 2006
393b612
--- tests/new-exp.right	Sun Oct 29 16:03:36 2006
393b612
***************
393b612
*** 430,436 ****
393b612
  Case06---1---A B C::---
393b612
  Case07---3---A:B:C---
393b612
  Case08---3---A:B:C---
393b612
! ./new-exp.tests: line 506: /${$(($#-1))}: bad substitution
393b612
  argv[1] = 
393b612
  argv[2] = 
393b612
  argv[3] = <c>
393b612
--- 430,436 ----
393b612
  Case06---1---A B C::---
393b612
  Case07---3---A:B:C---
393b612
  Case08---3---A:B:C---
393b612
! ./new-exp.tests: line 506: ${$(($#-1))}: bad substitution
393b612
  argv[1] = 
393b612
  argv[2] = 
393b612
  argv[3] = <c>
393b612
*** ../bash-3.2/patchlevel.h	Thu Apr 13 08:31:04 2006
393b612
--- patchlevel.h	Mon Oct 16 14:22:54 2006
393b612
***************
393b612
*** 26,30 ****
393b612
     looks for to find the patch level (for the sccs version string). */
393b612
  
393b612
! #define PATCHLEVEL 3
393b612
  
393b612
  #endif /* _PATCHLEVEL_H_ */
393b612
--- 26,30 ----
393b612
     looks for to find the patch level (for the sccs version string). */
393b612
  
393b612
! #define PATCHLEVEL 4
393b612
  
393b612
  #endif /* _PATCHLEVEL_H_ */