GNU bug report logs - #8102
[head] do not return EXIT_SUCCESS upon premature EOF

Previous Next

Package: coreutils;

Reported by: Bjartur Thorlacius <svartman95 <at> gmail.com>

Date: Wed, 23 Feb 2011 19:26:02 UTC

Severity: normal

Tags: notabug

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 8102 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Bjartur Thorlacius <svartman95 <at> gmail.com>
Cc: 8102 <at> debbugs.gnu.org
Subject: Re: bug#8102: [head] do not return EXIT_SUCCESS upon premature EOF
Date: Wed, 23 Feb 2011 13:16:00 -0700
[Message part 1 (text/plain, inline)]
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   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 13 years and 263 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.