From MAILER-DAEMON Sat Sep 03 12:50:47 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QztQc-0004uU-W7
	for mharc-bug-cppi@gnu.org; Sat, 03 Sep 2011 12:50:46 -0400
Received: from eggs.gnu.org ([140.186.70.92]:48433)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1QztQa-0004uL-J2
	for bug-cppi@gnu.org; Sat, 03 Sep 2011 12:50:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1QztQY-0000LI-Pt
	for bug-cppi@gnu.org; Sat, 03 Sep 2011 12:50:44 -0400
Received: from mx1.redhat.com ([209.132.183.28]:30376)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>)
	id 1QztQV-0000Kg-Un; Sat, 03 Sep 2011 12:50:40 -0400
Received: from int-mx01.intmail.prod.int.phx2.redhat.com
	(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p83GoVfm013995
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Sat, 3 Sep 2011 12:50:31 -0400
Received: from mx.meyering.net (ovpn01.gateway.prod.ext.phx2.redhat.com
	[10.5.9.1])
	by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
	id p83GoUZo018807; Sat, 3 Sep 2011 12:50:31 -0400
Received: from rho.meyering.net (localhost.localdomain [127.0.0.1])
	by rho.meyering.net (Acme Bit-Twister) with ESMTP id C98E760033;
	Sat,  3 Sep 2011 18:50:29 +0200 (CEST)
From: Jim Meyering <jim@meyering.net>
To: Egan McComb <egan.mccomb@gmail.com>
In-Reply-To: <87k4t3o96r.fsf@meyering.net> (Jim Meyering's message of "Tue, 23
	Mar 2010 07:15:24 +0100")
References: <87pr31o1xa.fsf@meyering.net> <874okcwc5w.fsf@gnu.org>
	<878w9n4cli.fsf@meyering.net> <4BA56639.6080809@draigBrady.com>
	<8739zux6xa.fsf@meyering.net> <4BA6E35C.8070205@draigBrady.com>
	<4BA74860.1030305@draigBrady.com> <4BA76581.3030308@draigBrady.com>
	<4BA78DD6.70809@redhat.com> <4BA79588.1070702@draigBrady.com>
	<87k4t3o96r.fsf@meyering.net>
Date: Sat, 03 Sep 2011 18:50:29 +0200
Message-ID: <874o0twox6.fsf@rho.meyering.net>
Lines: 73
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 209.132.183.28
Cc: bug-coreutils@gnu.org, bug-cppi@gnu.org,
	=?iso-8859-1?Q?P=E1draig?= Brady <P@draigBrady.com>,
	Giuseppe Scrivano <gscrivano@gnu.org>
Subject: Re: [bug-cppi] [PATCH] Add new option --in-place
X-BeenThere: bug-cppi@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: <bug-cppi.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-cppi>,
	<mailto:bug-cppi-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-cppi>
List-Post: <mailto:bug-cppi@gnu.org>
List-Help: <mailto:bug-cppi-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-cppi>,
	<mailto:bug-cppi-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 03 Sep 2011 16:50:45 -0000

Jim Meyering wrote:
> P=E1draig Brady wrote:
>> On 22/03/10 15:33, Eric Blake wrote:
>>> On 03/22/2010 06:41 AM, P=E1draig Brady wrote:
>>>> So that probably means we need to go with a different name.
>>>> `inplace` is the next best one I can think of which
>>>> at least mirrors the well known sed --in-place and perl -i options.
>>>
>>> inplace sounds like a decent name to me.  Sounds like an interesting
>>> filter to add.
>>
>> The name is not too bad, but it does annoy me a bit,
>> as commands are usually of the form
>>   verb --how
>> for e.g.
>>   sed --in-place
>>
>> But if we used `inplace` we'd change to:
>>   how "what" file...
>>
>> By using `replace` we would be back to the more normal form:
>>   replace "how" file...
>>
>> However `replace` is used by mysql-server as previously mentioned.
>> And `repl` is used by nmh. How about keeping with the terse unix
>> tradition while alluding to the relationship with cp/mv/rm by using...
>>
>> rp
>
> I wouldn't object.
>
> A possible bastardized compromise: re-place
> It's sort of analogous to in-place.

Picking up on an 18-month-old thread, Egan McComb found the
tool I'd seen: sponge:

  Egan McComb wrote:
  > On Sat, 20 Mar 2010 09:32:57 +0100, Jim Meyering wrote:
  >> I'm nearly certain I've seen a program (possibly a small perl script)
  >> that can effectively add the --in-place functionality to any filter
  >> program, but so far my searches have been in vain.
  >>
  >> I want a tool that works like this:
  >>
  >>     in-place [--backup] 'cppi ...options' *.c
  >>
  >> For each .c file, it would apply the filter program, and upon each
  >> successful exit, it would update the .c file in place (atomically, of
  >> course) with the output from the filter.
  >>
  >> Can anyone point to existing code that does that?
  >>
  >> Jim
  >
  > I know this is an old thread, but as far as I can tell the problem
  > hasn't yet been resolved.
  >
  > The program that works similarly is called sponge, from the moreutils
  > project at http://kitenet.net/~joey/code/moreutils/. It is used as a
  > filter in a pipe:
  >
  > 	for FILE in *.c; do cppi ...options $FILE | sponge; done
  >
  > I'm not sure if it fulfills the other considerations laid out in the
  > thread, but it is what I use when I need in-place editing of files.

Ahhh!  That's it.  Thank you!

    for FILE in *.c; do cppi ...options $FILE | sponge $FILE; done

It's a fine argument for not adding an --in-place option.
It could use a --backup option, though.


From MAILER-DAEMON Sat Sep 03 13:57:06 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QzuSo-00062Y-M9
	for mharc-bug-cppi@gnu.org; Sat, 03 Sep 2011 13:57:06 -0400
Received: from eggs.gnu.org ([140.186.70.92]:49220)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <P@draigBrady.com>) id 1QzuSm-0005zo-Cw
	for bug-cppi@gnu.org; Sat, 03 Sep 2011 13:57:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <P@draigBrady.com>) id 1QzuSl-0002j7-AP
	for bug-cppi@gnu.org; Sat, 03 Sep 2011 13:57:04 -0400
Received: from smtp2go.com ([207.58.142.213]:50285)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <P@draigBrady.com>)
	id 1QzuSi-0002iP-9k; Sat, 03 Sep 2011 13:57:00 -0400
Message-ID: <4E626A61.2020004@draigBrady.com>
Date: Sat, 03 Sep 2011 18:56:49 +0100
From: =?ISO-8859-1?Q?P=E1draig_Brady?= <P@draigBrady.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:5.0) Gecko/20110707 Thunderbird/5.0
MIME-Version: 1.0
To: Jim Meyering <jim@meyering.net>
References: <87pr31o1xa.fsf@meyering.net> <874okcwc5w.fsf@gnu.org>
	<878w9n4cli.fsf@meyering.net> <4BA56639.6080809@draigBrady.com>
	<8739zux6xa.fsf@meyering.net> <4BA6E35C.8070205@draigBrady.com>
	<4BA74860.1030305@draigBrady.com>
	<4BA76581.3030308@draigBrady.com> <4BA78DD6.70809@redhat.com>
	<4BA79588.1070702@draigBrady.com> <87k4t3o96r.fsf@meyering.net>
	<874o0twox6.fsf@rho.meyering.net>
In-Reply-To: <874o0twox6.fsf@rho.meyering.net>
X-Enigmail-Version: 1.2
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 207.58.142.213
Cc: bug-cppi@gnu.org, Egan McComb <egan.mccomb@gmail.com>,
	Coreutils <coreutils@gnu.org>, Giuseppe Scrivano <gscrivano@gnu.org>
Subject: Re: [bug-cppi] [PATCH] Add new option --in-place
X-BeenThere: bug-cppi@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: <bug-cppi.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-cppi>,
	<mailto:bug-cppi-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-cppi>
List-Post: <mailto:bug-cppi@gnu.org>
List-Help: <mailto:bug-cppi-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-cppi>,
	<mailto:bug-cppi-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 03 Sep 2011 17:57:05 -0000

On 09/03/2011 05:50 PM, Jim Meyering wrote:
> Jim Meyering wrote:
>> Pádraig Brady wrote:
>>> On 22/03/10 15:33, Eric Blake wrote:
>>>> On 03/22/2010 06:41 AM, Pádraig Brady wrote:
>>>>> So that probably means we need to go with a different name.
>>>>> `inplace` is the next best one I can think of which
>>>>> at least mirrors the well known sed --in-place and perl -i options.
>>>>
>>>> inplace sounds like a decent name to me.  Sounds like an interesting
>>>> filter to add.
>>>
>>> The name is not too bad, but it does annoy me a bit,
>>> as commands are usually of the form
>>>   verb --how
>>> for e.g.
>>>   sed --in-place
>>>
>>> But if we used `inplace` we'd change to:
>>>   how "what" file...
>>>
>>> By using `replace` we would be back to the more normal form:
>>>   replace "how" file...
>>>
>>> However `replace` is used by mysql-server as previously mentioned.
>>> And `repl` is used by nmh. How about keeping with the terse unix
>>> tradition while alluding to the relationship with cp/mv/rm by using...
>>>
>>> rp
>>
>> I wouldn't object.
>>
>> A possible bastardized compromise: re-place
>> It's sort of analogous to in-place.
> 
> Picking up on an 18-month-old thread, Egan McComb found the
> tool I'd seen: sponge:
> 
>   Egan McComb wrote:
>   > On Sat, 20 Mar 2010 09:32:57 +0100, Jim Meyering wrote:
>   >> I'm nearly certain I've seen a program (possibly a small perl script)
>   >> that can effectively add the --in-place functionality to any filter
>   >> program, but so far my searches have been in vain.
>   >>
>   >> I want a tool that works like this:
>   >>
>   >>     in-place [--backup] 'cppi ...options' *.c
>   >>
>   >> For each .c file, it would apply the filter program, and upon each
>   >> successful exit, it would update the .c file in place (atomically, of
>   >> course) with the output from the filter.
>   >>
>   >> Can anyone point to existing code that does that?
>   >>
>   >> Jim
>   >
>   > I know this is an old thread, but as far as I can tell the problem
>   > hasn't yet been resolved.
>   >
>   > The program that works similarly is called sponge, from the moreutils
>   > project at http://kitenet.net/~joey/code/moreutils/. It is used as a
>   > filter in a pipe:
>   >
>   > 	for FILE in *.c; do cppi ...options $FILE | sponge; done
>   >
>   > I'm not sure if it fulfills the other considerations laid out in the
>   > thread, but it is what I use when I need in-place editing of files.
> 
> Ahhh!  That's it.  Thank you!
> 
>     for FILE in *.c; do cppi ...options $FILE | sponge $FILE; done
> 
> It's a fine argument for not adding an --in-place option.
> It could use a --backup option, though.
> 

Yes a general "replace" util is preferable to --in-place options everywhere.
I noted previously that `sponge` was functionally equivalent to
method 6 here: http://www.pixelbeat.org/docs/unix_file_replacement.html

The latest (unfinished) inplace script I was working on is at:
http://lists.gnu.org/archive/html/bug-coreutils/2010-03/txt2gh88PrwZy.txt
It leverages coreutils quite well I think, including the --backup options.
It's on the TODO list to integrate, perhaps as a contrib dir of scripts.

cheers,
Pádraig.


