Subject: bug#8102: [head] do not return EXIT_SUCCESS upon premature EOF

From: Eric Blake <[email-masked]>
Date: Wed, 23 Feb 2011 13:16:00 -0700

On 02/23/2011 11:58 AM, Bjartur Thorlacius wrote:
> % echo | head -n2 && echo bug
> bug
> 
> This bit me when writing a line oriented prompter (which would `while
> head -n1`).
> 
> FYI, this also applies to FreeBSD head.

That's because this is not a bug, but a POSIX requirement:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/head.html

"When a file contains less than number lines, it shall be copied to
standard output in its entirety. This shall not be an error."

-- 
Eric Blake   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org