Re: sed -i



On Tue, Mar 27, 2007 at 12:11:06PM +0100, Alex Zbyslaw wrote:
Yar Tikhiy wrote:

Aren't sed's addresses required to be cumulative across its
input files?

http://www.opengroup.org/onlinepubs/009695399/utilities/sed.html



That makes sense for filter mode because it's equvalent to
concatenating the files in advance:

cat files ... | sed expression

OTOH, in-place mode selected by a -i option can be seen as follows:

for f in files ...; do
sed expression < $f > $f.tmp && mv $f $f.bak && mv $f.tmp $f
done

I.e., each file preserves its individuality. This can be at logical
conflict with cumulative addresses across all files.



As a Joe Random sed user, I'd agree with Yar. The GNU behaviour makes
more sense in most practical examples I can think of.

Perhaps a touch of feaping creaturism, but we could just add a -I flag
which behaved as -i does now, and make -i behave as GNU. I bet I
*could* construct examples where the current behaviour was what I desired.

Thank you for supporting me! I've just looked at the code and it
seems to me that it should be rather easy to preserve the current
semantics under a -I flag, too. They are too neat to throw them
away.

--
Yar
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"