Summary: | sed behavior change with a/i/c operands. | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Sergey <kpect> | ||||||
Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> | ||||||
Status: | Closed Overcome By Events | ||||||||
Severity: | Affects Many People | CC: | pfg | ||||||
Priority: | --- | Keywords: | patch, regression | ||||||
Version: | 11.0-STABLE | ||||||||
Hardware: | Any | ||||||||
OS: | Any | ||||||||
See Also: | https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208554 | ||||||||
Attachments: |
|
Description
Sergey
2016-10-14 09:30:00 UTC
I am not sure this can be classified as a regression. It is certainly a change in behavior with the idea of being more compatible with GNU sed: some people may be moving from linux to FreeBSD and may appreciate the compatibility. Standards don't force either behavior though, and I do see it would be somewhat advantageous to do some things different than GNU sed, but I am completely agnostic here. If we revert to the previous behavior I would prefer it be done fast but OTOH, the damage is already done for 11.0. Created attachment 175892 [details]
Proof-of-concept: provide a compile-time flag for GNU compatibility
An idea that could use polishing is to re-use the WITHOUT_GNU_SUPPORT to decide whether sed should attempt to behave in a GNU compatible way or not.
I am leaning towards defaulting to the previous behavior: as Sergey states, people can always install GNU sed if the want.
Created attachment 175985 [details]
Add a CFLAG to re-enable FreeBSD 10 behavior
The new behavior in FBSD 11+, is also present in SYSV UNIX. The new behavior should help people migrating from Solaris as well as linux so I think it should be the default.
It still looks convenient and easy to add a CFLAG (LEGACY_BSDSED_COMPAT) to make it easier to re-enable the old behavior.
I am not convinced we should go as far as adding a new build option for this, but at least this should make it easier to custom-build a sed that supports the old behavior.
(In reply to Pedro F. Giffuni from comment #3) In my humble opinion it's a bad decision. In that case i'd rather patch sed's source like this: # Restore original BSD sed sed -E -i '' \ -e '/ p = lbuf;/ a\ \ EATSPACE();' \ usr.bin/sed/compile.c I suppose FreeBSD shuld remain authenic and must not rush after Linux, as the ones who like Linux will use Linux, not BSD. FreeBSD should not copy or be 'like' Linux because it will never be on par with it... Why not to import coreutils in this case? FreeBSD has it's own benefits and should keep 'em. Those who migrate from Linux seek for something else/something new and not another linux with different name. Regards, Sergey. A commit references this bug: Author: pfg Date: Fri Nov 4 20:49:59 UTC 2016 New revision: 308314 URL: https://svnweb.freebsd.org/changeset/base/308314 Log: sed(1): add LEGACY_BSDSED_COMPAT compile-time flag. In r297602, which included a __FreeBSD_version bump to 1100105, we changed sed 'i' and 'a' from discarding whitespaces to conform with what GNU and sysvish sed do. There are arguments in favor of keeping the old behavior but the new behavior is also useful for migration purposes. It seems important to at least consider the case of developers depending on the previous behavior, so add a CFLAG to enable the old behaviour. PR: 213474 MFC after: 5 days Changes: head/usr.bin/sed/compile.c (In reply to commit-hook from comment #5) For the record: kib@ has suggested, and I agree, that an environment variable may be more convenient for this case. IMHO, the default should remain the current behavior. The naming of a descriptive environment variable, and perhaps even a patch for both code and manpage are welcome ;). IMHO it'd be better to leave BSD behavior as default one as anyone who likes may install GNU sed from ports (/usr/ports/textproc/gsed) together with GNU awk and bash to play with. A commit references this bug: Author: pfg Date: Wed Nov 9 18:00:50 UTC 2016 New revision: 308472 URL: https://svnweb.freebsd.org/changeset/base/308472 Log: MFC r308314: sed(1): add LEGACY_BSDSED_COMPAT compile-time flag. In r297602, which included a __FreeBSD_version bump to 1100105, we changed sed 'i' and 'a' from discarding whitespaces to conform with what GNU and sysvish sed do. There are arguments in favor of keeping the old behavior but the new behavior is also useful for migration purposes. It seems important to at least consider the case of developers depending on the previous behavior so add a CFLAG to enable the old behavior. PR: 213474 Changes: _U stable/11/ stable/11/usr.bin/sed/compile.c |