sed(1) is incompatible with its handling of the G and H commands
from FreeBSD PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=38195 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=29790
FreeBSD's sed(1) is incompatible with its handling of the G and H commands because it does not explicitly append newlines when appending a line of input, it relies on them just "popping up" because we use fgetln to get lines of input. This relates to appending the hold or pattern space.
The "G" command in sed does not conform to proper sed usage; command does not output a newline as stated in the manpage, nor as stated in the official sed FAQ.
This applies to ALL versions of FreeBSD (tested/verified on 2.2.8 and all 4.x revisions). This bug more than likely applies to OpenBSD and NetBSD as well.
Comments (3)
-
reporter -
reporter BUGFIX: Issue
#134-- fix sed(1) is incompatible with its handling of the G and H commands.see detailed information: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=29790 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=38195
patch taken from FreeBSD.
- FreeBSD
https://svnweb.freebsd.org/base?view=revision&revision=98601
Don't store newlines at the end of each line in the hold/pattern spaces, instead add the newline when the pattern space is printed. Make the
G' and
H' commands add a newline to the space before the data, remove bogus addition of newline from `x' command.PR: 29790, 38195
https://svnweb.freebsd.org/base?view=revision&revision=98603
Now that the pattern space contains no trailing newline, modify the `l' command's output so it's the same as what SUSv3 specifies.
https://svnweb.freebsd.org/base?view=revision&revision=170605
There is a symbolic antonym for REPLACE as a flag to cspace() and mf_fgets(): APPEND. So use it instead of a 0 constant for clarity.
Tested with: md5(1)
TNF HEAD and OpenBSD already merged this fix. but the fixes are mixed together with other functional changes (such as -i inplace edit implemetation).
→ <<cset 44234ca56f25>>
- FreeBSD
https://svnweb.freebsd.org/base?view=revision&revision=98601
-
reporter - edited description
- Log in to comment
try following: