GNU bug report logs -
#19240
cut 8.22 adds newline
Previous Next
Reported by: John Kendall <john <at> capps.com>
Date: Mon, 1 Dec 2014 16:44:01 UTC
Severity: normal
Tags: notabug
Done: Eric Blake <eblake <at> redhat.com>
Bug is archived. No further changes may be made.
Full log
Message #15 received at 19240 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
[re-adding the bug, with permission]
On 12/01/2014 01:10 PM, John Kendall wrote:
> Thanks, Eric.
>
> My only, admittedly weak, rebuttal is that the behavior of sort might not
> be the best behavior to imitate. It's understandable why POSIX defines
> how sort behaves, since it's intended for multi-line input.
>
> It seems sed, which is frequently used for single lines of input, might be
> a better analogy. Gnu sed 4.2.2 and solaris sed act the same way as
> solaris cut (no newline added):
>
> $ printf "ooooooooooo" | sed 's/o/p/g'
> ppppppppppp$
As a counter-argument, I recall hearing of other implementations of sed
that silently omit a trailing line that lacks a newline. And perhaps
GNU sed should be changed to always emit a trailing newline, but that's
something to bring up on the sed mailing list :)
>
>
> If my weak rebuttal is unconvincing, then I wonder if a note could be
> added to the cut man page so that the next porter can find an answer
> a little easier. As an interesting counterpoint, the Solaris version of
> sort announces loudly when it does what POSIX requires:
>
> $ printf "ooooooooooo" | sort
> sort: missing NEWLINE added at end of input file STDIN
> ooooooooooo
> $
Ouch - that's a bug in Solaris. POSIX does not allow for noise on
stderr when giving a default 0 success exit status.
>
>
>
> Thanks for taking the time to clarify this. I've been using SunOS and
> Solaris exclusively since 1992, so I've had a stable environment and
> was oblivious to the unspecified behavior that my scripts depended on.
>
> Cheers,
> John
>
I'll leave it to other contributors to weigh in on whether omitting the
final newline on output when it was missing on input is worth the
complexity of a change.
--
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 10 years and 171 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.