Date: Wed, 04 Feb 2026 10:21:42 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 292912] usr.bin/sed: allow comments after s/// Message-ID: <bug-292912-227-pR1rHCdYWj@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-292912-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292912 Dag-Erling Smørgrav <des@FreeBSD.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |des@FreeBSD.org Resolution|--- |Works As Intended Status|New |Closed --- Comment #1 from Dag-Erling Smørgrav <des@FreeBSD.org> --- There is no foundation in either POSIX or the GNU sed manual for your claim that comments should be allowed after a command. Both POSIX and the GNU sed manual describe '#' solely as a command which causes the rest of the line to be ignored. Like any other command, it must be separated from a preceding command by either a semicolon or a blank line. So these variants are allowed by POSIX and supported by BSD sed: % echo foo | sed -e 's/foo/bar/; # comment' bar % echo foo | sed -e $'s/foo/bar/\n# comment' bar % echo foo | sed -e 's/foo/bar/' -e '# comment' bar but this variant is neither allowed by POSIX nor supported by BSD sed: % echo foo | sed -e 's/foo/bar/ # comment' sed: 1: "s/foo/bar/ # comment ": bad flag in substitute command: '#' This last variant appears to be supported by GNU sed, but, importantly, not mentioned in the documentation. The passage you quote from the GNU sed manual does not refer to comments that follow a command, but to the fact that some implementations (not including BSD sed) only allow a comment on the first line of the script. -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-292912-227-pR1rHCdYWj>
