GNU bug report logs - #26574
v4.4: POSIX violation with respect to output of a trailing newline, even with --posix

Previous Next

Package: sed;

Reported by: Michael Klement <michael.klement <at> usa.net>

Date: Thu, 20 Apr 2017 04:00:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


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

From: Michael Klement <michael.klement <at> usa.net>
To: bug-sed <at> gnu.org
Subject: v4.4: POSIX violation with respect to output of a trailing newline,
 even with --posix
Date: Wed, 19 Apr 2017 21:43:15 -0400
[Message part 1 (text/plain, inline)]
$ sed --version
sed (GNU sed) 4.4

The POSIX spec. <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html> states:
"Whenever the pattern space is written to standard output or a named file, sed shall immediately follow it with a <newline>."

While GNU Sed's default behavior of preserving the trailing-newline status of the input's last line is defensible and can be helpful,
it should exhibit POSIX-compliant behavior when invoked with --posix.

# Acceptable default behavior - the no-trailing-newline status of the input is preserved.
$ printf 'a' | sed '' | od -t x1
0000000    61


# SHOULD include a trailing newline, per POSIX, but currently doesn't.
$ printf 'a' | sed --posix '' | od -t x1
0000000    61



Regards,

Michael
[Message part 2 (text/html, inline)]

This bug report was last modified 8 years and 84 days ago.

Previous Next


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