Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Mar 2007 20:30:54 +0300
From:      Diomidis Spinellis <dds@aueb.gr>
To:        Yar Tikhiy <yar@comp.chem.msu.su>
Cc:        hackers@freebsd.org
Subject:   Re: sed -i
Message-ID:  <460D494E.3030106@aueb.gr>
In-Reply-To: <20070330172133.GD98431@comp.chem.msu.su>
References:  <20070326135106.GG60831@comp.chem.msu.su> <460B76A0.5030200@aueb.gr> <20070330172133.GD98431@comp.chem.msu.su>

next in thread | previous in thread | raw e-mail | index | archive | help
Yar Tikhiy wrote:
> May I take a bit more of your time?
> 
> I've started playing with the code and noticed another gray area.
> Namely a `c' command won't print the text if having 2 addresses
> with the 2nd address beyond the actual end of file.  For example:
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BEGIN
> $ jot 9 |
>> sed '6,15c\
>> text
>> ' test
> 1
> 2
> 3
> 4
> 5
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END
> 
> Ditto with RE's, if the 2nd RE doesn't match any line:
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BEGIN
> $ jot 9 | sed '/6/,/15/c\
>> text
>> ' test
> 1
> 2
> 3
> 4
> 5
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END
> 
> If we've started to delete the pattern space, we should print the
> text in place of it because `c' is for `change'.  BSD and GNU seds
> have this bug, but Solaris sed doesn't have it.  Do you think we
> should fix it, too?
> 
> Thanks!
> 

Yes, it sounds like a bug to me.  Note that a couple of weeks ago I 
added the regression tests I originally wrote in 1992 to the FreeBSD 
regression test suite.  Given that you are writing test cases it would 
be very nice to follow the format used in 
src/tools/regression/usr.bin/sed/regress.t, so that we can add them to 
the test suite.

Diomidis



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