bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19240: cut 8.22 adds newline


From: Eric Blake
Subject: bug#19240: cut 8.22 adds newline
Date: Mon, 01 Dec 2014 10:05:37 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

tag 19240 notabug
thanks

On 12/01/2014 06:39 AM, John Kendall wrote:
> Hi,
> 
> I don't know if this is a bug, but I wonder if there is a consensus on 
> correct behavior.
> The solaris version of cut does not add a newline if there was no newline on 
> the input:

Such an input is not a text file (the POSIX definition of text file
requires that if the file is not empty, it ends in newline); and POSIX
leaves the behavior of 'cut' unspecified if it is not operating on a
text file.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_397

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

Therefore, it is unspecified whether cut will add or skip a trailing
newline.

> 
> I came upon this while porting scripts from Solaris 10 to Centos 7.

GNU chose to make cut behave similarly to sort, which IS required to add
a trailing newline even when the input lacks one (that is, POSIX goes
the extra mile and defines sort behavior on non-text files that are
non-text only because they lack a newline).  Solaris chose differently.
 But the problem is that you are relying on unspecified behavior; fix
your input files to have a trailing newline, then you won't have to
worry about it.

At any rate, I see no reason to change GNU behavior, so I'm closing this
as not a bug.  Feel free to add further comments, though, including if
you have a stronger argument for why we should reopen the bug and change
behavior.

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]