Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 May 2002 15:54:05 -0700
From:      "David O'Brien" <obrien@FreeBSD.ORG>
To:        "J. Mallett" <jmallett@FreeBSD.ORG>
Cc:        cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/usr.bin/sed main.c sed.1
Message-ID:  <20020507155405.A31179@dragon.nuxi.com>
In-Reply-To: <20020507214610.GA30780@FreeBSD.ORG>; from jmallett@FreeBSD.ORG on Tue, May 07, 2002 at 09:46:11PM %2B0000
References:  <200205071832.g47IWJO26790@freefall.freebsd.org> <20020507214610.GA30780@FreeBSD.ORG>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 07, 2002 at 09:46:11PM +0000, J. Mallett wrote:
> On Tue, May 07, 2002 at 11:32:18AM -0700, J. Mallett wrote:
> > jmallett    2002/05/07 11:32:18 PDT
> > 
> >   Modified files:
> >     usr.bin/sed          main.c sed.1 
> >   Log:
> >   Add a -i option to sed(1) to do inplace editing, to give us an
> >   alternative to Perl for such things.

Actually looking at this, you are not doing things in the most robust
order:

    sed -i.bak -e s/A/B/ foo

should:

    open foo for reading
    create tmpfile for output
    read from foo,
    do /A/B/
    write to tmpfile
    IF successful
        rename foo to foo.bak
        rename tmpfile to foo

Anything else is not robust in the face of ^C, etc...

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




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