-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 6/20/12 3:09 AM, Dan Douglas wrote:
> Bash Version: 4.2
> Patch Level: 29
> Release Status: release
>
> Description:
> mapfile -n eats a line too many, discarding the last.
Thanks for the report. Try the attached patch; it appears to fix the
issue.
Chet
- --
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk/h2GgACgkQu1hp8GTqdKt7gACfa1mSIDbIr403Dm0eSveLwiuv
L1gAn3rIGbLo/V+Eqh6FShzCQ7T2S4dG
=wh/y
-----END PGP SIGNATURE-----
*** ../bash-4.2-patched/builtins/mapfile.def 2010-05-29 22:09:47.000000000 -0400
--- builtins/mapfile.def 2012-06-20 09:48:33.000000000 -0400
***************
*** 196,206 ****
interrupt_immediately++;
for (array_index = origin, line_count = 1;
! zgetline (fd, &line, &line_length, unbuffered_read) != -1;
! array_index++, line_count++)
{
- /* Have we exceeded # of lines to store? */
- if (line_count_goal != 0 && line_count > line_count_goal)
- break;
-
/* Remove trailing newlines? */
if (flags & MAPF_CHOP)
--- 196,202 ----
interrupt_immediately++;
for (array_index = origin, line_count = 1;
! zgetline (fd, &line, &line_length, unbuffered_read) != -1;
! array_index++)
{
/* Remove trailing newlines? */
if (flags & MAPF_CHOP)
***************
*** 218,221 ****
--- 214,222 ----
bind_array_element (entry, array_index, line, 0);
+
+ /* Have we exceeded # of lines to store? */
+ line_count++;
+ if (line_count_goal != 0 && line_count > line_count_goal)
+ break;
}