Sed substitution bugs
tjr at FreeBSD.ORG
Tue Jun 3 18:35:39 PDT 2003
On Tue, Jun 03, 2003 at 03:42:25PM +0100, Tony Finch wrote:
> $ echo foo | sed 's/ */,/g'
> On Solaris and Linux I get ,f,o,o, (which is what I expected).
It looks like I may have introduced this bug when I made the semi-dramatic
change of making 'sed' not store newlines in the line buffers -- OpenBSD's sed
gives the right result. I agree that the current output is wrong and that
it should be ",f,o,o,".
FWIW, 7th Edition sed gets into an infinite loop on that input.
> The following work correctly:
> $ echo | sed 's/ */,/g'
> $ echo foo | sed 's/ *$/,/g'
> Here's another (related) bug:
I can't claim responsibility for this one :-) But I agree that it looks like a
> $ echo foo | sed 's/ */,/1'
> $ echo foo | sed 's/ */,/2'
> $ echo foo | sed 's/ */,/3'
> $ echo foo | sed 's/ */,/4'
> $ echo foo | sed 's/ */,/5'
The patch looks fine, but it isn't obvious to me that the second part
(handling the /nnn bits) is correct. It seems to produce the right output
More information about the freebsd-standards