Date: Fri, 30 Mar 2007 20:01:19 +0400 From: Yar Tikhiy <yar@comp.chem.msu.su> To: Alex Zbyslaw <xfb52@dial.pipex.com> Cc: hackers@freebsd.org Subject: Re: sed -i Message-ID: <20070330160119.GC98431@comp.chem.msu.su> In-Reply-To: <4608FBCA.2060302@dial.pipex.com> References: <20070326135106.GG60831@comp.chem.msu.su> <84dead720703260827q29ed7f26hd79dde461fe50d9b@mail.gmail.com> <20070327075934.GA10930@comp.chem.msu.su> <4608FBCA.2060302@dial.pipex.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070330160119.GC98431>