462fb2
			     BASH PATCH REPORT
462fb2
			     =================
462fb2
462fb2
Bash-Release:	4.2
462fb2
Patch-ID:	bash42-035
462fb2
462fb2
Bug-Reported-by:	Dan Douglas <ormaaj@gmail.com>
462fb2
Bug-Reference-ID:	<2766482.Ksm3GrSoYi@smorgbox>
462fb2
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2012-06/msg00071.html
462fb2
462fb2
Bug-Description:
462fb2
462fb2
When given a number of lines to read, `mapfile -n lines' reads one too many.
462fb2
462fb2
Patch (apply with `patch -p0'):
462fb2
462fb2
*** ../bash-4.2-patched/builtins/mapfile.def	2010-05-29 22:09:47.000000000 -0400
462fb2
--- builtins/mapfile.def	2012-06-20 09:48:33.000000000 -0400
462fb2
***************
462fb2
*** 196,206 ****
462fb2
    interrupt_immediately++;
462fb2
    for (array_index = origin, line_count = 1; 
462fb2
!        zgetline (fd, &line, &line_length, unbuffered_read) != -1;
462fb2
!        array_index++, line_count++) 
462fb2
      {
462fb2
-       /* Have we exceeded # of lines to store? */
462fb2
-       if (line_count_goal != 0 && line_count > line_count_goal) 
462fb2
- 	break;
462fb2
- 
462fb2
        /* Remove trailing newlines? */
462fb2
        if (flags & MAPF_CHOP)
462fb2
--- 196,202 ----
462fb2
    interrupt_immediately++;
462fb2
    for (array_index = origin, line_count = 1; 
462fb2
!  	zgetline (fd, &line, &line_length, unbuffered_read) != -1;
462fb2
! 	array_index++) 
462fb2
      {
462fb2
        /* Remove trailing newlines? */
462fb2
        if (flags & MAPF_CHOP)
462fb2
***************
462fb2
*** 218,221 ****
462fb2
--- 214,222 ----
462fb2
  
462fb2
        bind_array_element (entry, array_index, line, 0);
462fb2
+ 
462fb2
+       /* Have we exceeded # of lines to store? */
462fb2
+       line_count++;
462fb2
+       if (line_count_goal != 0 && line_count > line_count_goal) 
462fb2
+ 	break;
462fb2
      }
462fb2
  
462fb2
*** ../bash-4.2-patched/patchlevel.h	Sat Jun 12 20:14:48 2010
462fb2
--- patchlevel.h	Thu Feb 24 21:41:34 2011
462fb2
***************
462fb2
*** 26,30 ****
462fb2
     looks for to find the patch level (for the sccs version string). */
462fb2
  
462fb2
! #define PATCHLEVEL 34
462fb2
  
462fb2
  #endif /* _PATCHLEVEL_H_ */
462fb2
--- 26,30 ----
462fb2
     looks for to find the patch level (for the sccs version string). */
462fb2
  
462fb2
! #define PATCHLEVEL 35
462fb2
  
462fb2
  #endif /* _PATCHLEVEL_H_ */