GNU bug report logs -
#54614
GNU Sed 's/.../\n/' disagreement with POSIX
Previous Next
To reply to this bug, email your comments to 54614 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-sed <at> gnu.org
:
bug#54614
; Package
sed
.
(Mon, 28 Mar 2022 17:21:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
New bug report received and forwarded. Copy sent to
bug-sed <at> gnu.org
.
(Mon, 28 Mar 2022 17:21:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
POSIX says that this shell command:
echo 'abc' | sed 's/b/\n/g'
should output 'anc', but with GNU Sed it outputs two lines 'a' and 'c',
even if POSIXLY_CORRECT is set.
Traditional Sed (e.g., Solaris, AIX 7) conforms to POSIX. FreeBSD Sed
agrees with GNU Sed though, and I would guess that that GNU Sed's
behavior is probably more expected. However, this disagreement with
POSIX should be documented in the GNU Sed manual (and the manual should
recommend backslash-newline over backslash-'n' for portability), and if
POSIXLY_CORRECT is set, GNU Sed should conform to POSIX.
Information forwarded
to
bug-sed <at> gnu.org
:
bug#54614
; Package
sed
.
(Mon, 28 Mar 2022 18:40:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
On 3/28/22 10:20, Paul Eggert wrote:
> POSIX says that this shell command:
>
> echo 'abc' | sed 's/b/\n/g'
>
> should output 'anc', but with GNU Sed it outputs two lines 'a' and 'c',
> even if POSIXLY_CORRECT is set.
Oh, a further reading of the POSIX spec indicates that the behavior is
unspecified here. So, please ignore what I wrote about POSIXLY_CORRECT
etc.; the current GNU Sed behavior is fine. Though it may be helpful to
document the unportability of \n here.
This bug report was last modified 2 years and 241 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.