Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jun 2003 11:32:29 +1000
From:      Tim Robbins <tjr@FreeBSD.ORG>
To:        Tony Finch <dot@dotat.at>
Cc:        freebsd-standards@freebsd.org
Subject:   Re: Sed substitution bugs
Message-ID:  <20030604113229.A41800@dilbert.robbins.dropbear.id.au>
In-Reply-To: <20030603144225.GH18938@chiark.greenend.org.uk>; from dot@dotat.at on Tue, Jun 03, 2003 at 03:42:25PM %2B0100
References:  <20030603144225.GH18938@chiark.greenend.org.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jun 03, 2003 at 03:42:25PM +0100, Tony Finch wrote:

> $ echo foo | sed 's/ */,/g'
> ,f,o,o
> $
> 
> 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'
> foo,
> $
> 
> Here's another (related) bug:

I can't claim responsibility for this one :-) But I agree that it looks like a
bug.

> 
> $ echo foo | sed 's/ */,/1'
> ,foo
> $ echo foo | sed 's/ */,/2'
> ,foo
> $ echo foo | sed 's/ */,/3'
> ,foo
> $ echo foo | sed 's/ */,/4'
> ,foo
> $ echo foo | sed 's/ */,/5'
> ,foo
> $ 

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
though.


Tim



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030604113229.A41800>