bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9430: [PATCH] Add new option --in-place


From: Jim Meyering
Subject: bug#9430: [PATCH] Add new option --in-place
Date: Sat, 03 Sep 2011 18:50:29 +0200

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]