Roman Rakus dbeb5d
			     BASH PATCH REPORT
Roman Rakus dbeb5d
			     =================
Roman Rakus dbeb5d
Roman Rakus dbeb5d
Bash-Release:	4.0
Roman Rakus dbeb5d
Patch-ID:	bash40-025
Roman Rakus dbeb5d
Roman Rakus dbeb5d
Bug-Reported-by:	Matt Zyzik <matt.zyzik@nyu.edu>
Roman Rakus dbeb5d
Bug-Reference-ID:	<20090519011418.GA21431@ice.filescope.com>
Roman Rakus dbeb5d
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2009-05/msg00044.html
Roman Rakus dbeb5d
Roman Rakus dbeb5d
Bug-Description:
Roman Rakus dbeb5d
Roman Rakus dbeb5d
bash40-024 introduced a regression for constructs like **/*.cs; that
Roman Rakus dbeb5d
expansion would no longer include matching files in the current directory.
Roman Rakus dbeb5d
This patch undoes portions of bash40-024 and fixes the original problem
Roman Rakus dbeb5d
in a different way.
Roman Rakus dbeb5d
Roman Rakus dbeb5d
Patch:
Roman Rakus dbeb5d
Roman Rakus dbeb5d
*** ../bash-4.0-patched/lib/glob/glob.c	2009-05-22 12:32:26.000000000 -0400
Roman Rakus dbeb5d
--- lib/glob/glob.c	2009-05-22 12:35:55.000000000 -0400
Roman Rakus dbeb5d
***************
Roman Rakus dbeb5d
*** 666,672 ****
Roman Rakus dbeb5d
      }
Roman Rakus dbeb5d
  
Roman Rakus dbeb5d
!   /* compat: if GX_ALLDIRS, add the passed directory also, but don't add an
Roman Rakus dbeb5d
!      empty directory name. */
Roman Rakus dbeb5d
!   if (add_current && (flags & GX_NULLDIR) == 0)
Roman Rakus dbeb5d
      {
Roman Rakus dbeb5d
        sdlen = strlen (dir);
Roman Rakus dbeb5d
--- 666,673 ----
Roman Rakus dbeb5d
      }
Roman Rakus dbeb5d
  
Roman Rakus dbeb5d
!   /* compat: if GX_ADDCURDIR, add the passed directory also.  Add an empty
Roman Rakus dbeb5d
!      directory name as a placeholder if GX_NULLDIR (in which case the passed
Roman Rakus dbeb5d
!      directory name is "."). */
Roman Rakus dbeb5d
!   if (add_current)
Roman Rakus dbeb5d
      {
Roman Rakus dbeb5d
        sdlen = strlen (dir);
Roman Rakus dbeb5d
***************
Roman Rakus dbeb5d
*** 680,684 ****
Roman Rakus dbeb5d
  	  nextlink->next = lastlink;
Roman Rakus dbeb5d
  	  lastlink = nextlink;
Roman Rakus dbeb5d
! 	  bcopy (dir, nextname, sdlen + 1);
Roman Rakus dbeb5d
  	  ++count;
Roman Rakus dbeb5d
  	}
Roman Rakus dbeb5d
--- 681,688 ----
Roman Rakus dbeb5d
  	  nextlink->next = lastlink;
Roman Rakus dbeb5d
  	  lastlink = nextlink;
Roman Rakus dbeb5d
! 	  if (flags & GX_NULLDIR)
Roman Rakus dbeb5d
! 	    nextname[0] = '\0';
Roman Rakus dbeb5d
! 	  else
Roman Rakus dbeb5d
! 	    bcopy (dir, nextname, sdlen + 1);
Roman Rakus dbeb5d
  	  ++count;
Roman Rakus dbeb5d
  	}
Roman Rakus dbeb5d
***************
Roman Rakus dbeb5d
*** 1008,1016 ****
Roman Rakus dbeb5d
        /* Just return what glob_vector () returns appended to the
Roman Rakus dbeb5d
  	 directory name. */
Roman Rakus dbeb5d
        dflags = flags & ~GX_MARKDIRS;
Roman Rakus dbeb5d
        if (directory_len == 0)
Roman Rakus dbeb5d
  	dflags |= GX_NULLDIR;
Roman Rakus dbeb5d
        if ((flags & GX_GLOBSTAR) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
Roman Rakus dbeb5d
! 	dflags |= GX_ALLDIRS|GX_ADDCURDIR;
Roman Rakus dbeb5d
        temp_results = glob_vector (filename,
Roman Rakus dbeb5d
  				  (directory_len == 0 ? "." : directory_name),
Roman Rakus dbeb5d
--- 1012,1033 ----
Roman Rakus dbeb5d
        /* Just return what glob_vector () returns appended to the
Roman Rakus dbeb5d
  	 directory name. */
Roman Rakus dbeb5d
+       /* If flags & GX_ALLDIRS, we're called recursively */
Roman Rakus dbeb5d
        dflags = flags & ~GX_MARKDIRS;
Roman Rakus dbeb5d
        if (directory_len == 0)
Roman Rakus dbeb5d
  	dflags |= GX_NULLDIR;
Roman Rakus dbeb5d
        if ((flags & GX_GLOBSTAR) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
Roman Rakus dbeb5d
! 	{
Roman Rakus dbeb5d
! 	  dflags |= GX_ALLDIRS|GX_ADDCURDIR;
Roman Rakus dbeb5d
! #if 0
Roman Rakus dbeb5d
! 	  /* If we want all directories (dflags & GX_ALLDIRS) and we're not
Roman Rakus dbeb5d
! 	     being called recursively as something like `echo **/*.o'
Roman Rakus dbeb5d
! 	     ((flags & GX_ALLDIRS) == 0), we want to prevent glob_vector from
Roman Rakus dbeb5d
! 	     adding a null directory name to the front of the temp_results
Roman Rakus dbeb5d
! 	     array.  We turn off ADDCURDIR if not called recursively and
Roman Rakus dbeb5d
! 	     dlen == 0 */
Roman Rakus dbeb5d
! #endif
Roman Rakus dbeb5d
! 	  if (directory_len == 0 && (flags & GX_ALLDIRS) == 0)
Roman Rakus dbeb5d
! 	    dflags &= ~GX_ADDCURDIR;
Roman Rakus dbeb5d
! 	}
Roman Rakus dbeb5d
        temp_results = glob_vector (filename,
Roman Rakus dbeb5d
  				  (directory_len == 0 ? "." : directory_name),
Roman Rakus dbeb5d
*** ../bash-4.0/patchlevel.h	2009-01-04 14:32:40.000000000 -0500
Roman Rakus dbeb5d
--- patchlevel.h	2009-02-22 16:11:31.000000000 -0500
Roman Rakus dbeb5d
***************
Roman Rakus dbeb5d
*** 26,30 ****
Roman Rakus dbeb5d
     looks for to find the patch level (for the sccs version string). */
Roman Rakus dbeb5d
  
Roman Rakus dbeb5d
! #define PATCHLEVEL 24
Roman Rakus dbeb5d
  
Roman Rakus dbeb5d
  #endif /* _PATCHLEVEL_H_ */
Roman Rakus dbeb5d
--- 26,30 ----
Roman Rakus dbeb5d
     looks for to find the patch level (for the sccs version string). */
Roman Rakus dbeb5d
  
Roman Rakus dbeb5d
! #define PATCHLEVEL 25
Roman Rakus dbeb5d
  
Roman Rakus dbeb5d
  #endif /* _PATCHLEVEL_H_ */