[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8102: [head] do not return EXIT_SUCCESS upon premature EOF
From: |
Eric Blake |
Subject: |
bug#8102: [head] do not return EXIT_SUCCESS upon premature EOF |
Date: |
Wed, 23 Feb 2011 13:16:00 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7 |
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 address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature