From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 30 16:01:30 2007 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2C24C16A400 for ; Fri, 30 Mar 2007 16:01:30 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.freebsd.org (Postfix) with ESMTP id 8D80713C4C2 for ; Fri, 30 Mar 2007 16:01:29 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.4) with ESMTP id l2UG1PtS003120; Fri, 30 Mar 2007 20:01:25 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.4/Submit) id l2UG1Jag003116; Fri, 30 Mar 2007 20:01:19 +0400 (MSD) (envelope-from yar) Date: Fri, 30 Mar 2007 20:01:19 +0400 From: Yar Tikhiy To: Alex Zbyslaw Message-ID: <20070330160119.GC98431@comp.chem.msu.su> References: <20070326135106.GG60831@comp.chem.msu.su> <84dead720703260827q29ed7f26hd79dde461fe50d9b@mail.gmail.com> <20070327075934.GA10930@comp.chem.msu.su> <4608FBCA.2060302@dial.pipex.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4608FBCA.2060302@dial.pipex.com> User-Agent: Mutt/1.5.9i Cc: hackers@freebsd.org Subject: Re: sed -i X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Mar 2007 16:01:30 -0000 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