https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292912
Bug ID: 292912
Summary: usr.bin/sed: allow comments after s///
Product: Base System
Version: 16.0-CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Many People
Priority: ---
Component: bin
Assignee: [email protected]
Reporter: [email protected]
Created attachment 267742
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=267742&action=edit
sed to allow # comments after s///
Hello,
According to POSIX SED conformance, it should be possible to use comments (#)
not only on the first line of a SED script, but anywhere at the end flags, with
all text after the comment character (#) being ignored until a new line is
encountered.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
But on FreeBSD, we got an error:
# sed -e 's/word/newword/ #comments' test.txt
sed: 1: "s/word/newword/ #comments
": bad flag in substitute command: '#'
On GNU sed, it works. On man page
(https://www.gnu.org/software/sed/manual/sed.html#index-_0023-_0028comments_0029),
we can see:
“3.4… be aware that some implementations of sed (which are not POSIX
conforming) may only support a single one-line comment, and then only when the
very first character of the script is a #.”
Therefore, I suggest accepting # as a comment when used after the last flags,
in accordance with POSIX.
Thanks
--
You are receiving this mail because:
You are the assignee for the bug.