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

From: Michael Klement <[email-masked]>
Date: Wed, 19 Apr 2017 21:43:15 -0400

$ 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