[Bug 254091] sed: Please fix -i behavior
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sun Mar 7 09:47:07 UTC 2021
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254091
Bug ID: 254091
Summary: sed: Please fix -i behavior
Product: Base System
Version: Unspecified
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: bin
Assignee: bugs at FreeBSD.org
Reporter: tobik at freebsd.org
Created attachment 223048
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=223048&action=edit
sed.diff
This is one of the most frustrating things in FreeBSD userland for me
and can be a PITA when creating new ports or updating them because the
rest of the world expects sed to behave differently than our sed. I'm
sure this has come up before but I could not find a bug for it.
Our sed uses getopt("i:") instead of getopt("i::") like GNU sed or
even NetBSD sed or OpenBSD sed. As a consequence something like
`sed -i 's/foo/bar/' file` will not work on FreeBSD but works just
fine on Linux/NetBSD/OpenBSD (our sed interprets `s/foo/bar/` as
the backup file suffix and `file` as the expression, whereas
GNU/NetBSD/OpenBSD sed see that we want no backup file).
For a concrete example of something in the wild, this here is from
the editors/mg configure script which is fine with the other seds
sed -i 's,<term.h>,"terminfo_term.h",g' display.c
but errors out with ours
sed: 1: "display.c": extra characters at the end of d command
If have sent a patch for this upstream to "fix" it, but really it
is sed(1) that should be fixed and should be made to work like the
rest of the world. We should deal with the consequences on our
side. I have a hard time sending patches like this upstream without
flinching because I'm essentially pushing a fix for a FreeBSD bug
onto upstream.
It has been like this forever and FWICT it has been copied to macOS
too, so maybe it is too late now... Changing this is obviously a
POLA violation and will break scripts of many users but it would
be nice if we could do it for FreeBSD 14 anyway.
I'm attaching a patch that does what I want I think but most of the
tests and other scripts in the tree are broken since they all use bad
sed calls now. Ironically there also seem to be some scripts in the
tree that are obviously broken with FreeBSD sed and expect GNU sed
behavior (for example release/tools/gce.conf).
I'd be willing to help fix any ports fallout caused by this.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list