GNU bug report logs - #16329
`head --lines=-0' prints nothing if no newline at the EOF

Previous Next

Package: coreutils;

Reported by: Алексей Шилин <rootlexx <at> mail.ru>

Date: Fri, 3 Jan 2014 16:31:01 UTC

Severity: normal

Merged with 16559, 16560, 16561

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eric Blake <eblake <at> redhat.com>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 16329 <at> debbugs.gnu.org, Алексей Шилин <rootlexx <at> mail.ru>
Subject: bug#16329: `head --lines=-0' prints nothing if no newline at the EOF
Date: Fri, 03 Jan 2014 10:10:09 -0700
[Message part 1 (text/plain, inline)]
On 01/03/2014 10:02 AM, Pádraig Brady wrote:
>>> It depends on whether the file has a trailing newline.
>>
>> Per POSIX, 'head' is only required to operate on "text files"
>> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/head.html
>> and a "text file" must either be empty or have a trailing newline:
>> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_397
>>
>> So this is not necessarily a bug.  That said, since POSIX doesn't
>> specify what we should do, we are free to make it behave differently.
> 
> BTW I still don't think POSIX is specifying that text files without
> a trailing newline are not text files.
> 
> It states that text files can have zero or more lines,

Where "lines" is also a well-defined POSIX term:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206

> implying that the trailing new line is optional.

Wrong.  The trailing newline character is mandatory in text files.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

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

This bug report was last modified 11 years and 175 days ago.

Previous Next


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