On Thu, Nov 27, 2008 at 08:20:02AM +0000, hv@crypt.org wrote:
> Chip Salzenberg <chip@pobox.com> wrote:
> :Summarizing the plan:
> :
> : * -ix means to set $^I="x"
> : * -jx means to set $^I="x" and ${^INPLACE_SAFE}=1
> : * if ${^INPLACE_SAFE} is true and $^I is nonempty, then <> does this:
> : > open ARGV, '<', $ARGV
> : > open ARGVOUT, '>', "$ARGV$^I"
> : > rename "$ARGV^I", $ARGV # on successful completion
> :
> :Comments?
>
> New commandline flags are rare and expensive, but I can just about see the
> value here (even if the problem being solved barely registered as an itch
> for me - I usually use the cavalier '-pi -wle').
I hate to do it, but we do want safety convenient, do we not? We could be
somewhat hackier and take advantage of the fact that "*" is already special
in the -i string. Using a double star means twice as good a backup:
-i.bak - unsafe .bak
-i'*.bak' - unsafe .bak
-i'**.bak' - safe .bak
Simpler in a way, more complex in another way.
> As defined here, when x is empty, -j is the same as -i. Should it do
> something more useful, like backup to a tempfile and delete on successful
> completion?
Yes, this is a Good Idea.
--
Chip Salzenberg twitter:chipsalz
"UTOPIA PLANITIA IS IN ORBIT is the new HAN SHOT FIRST" - Crisper Than Thou
Thread Previous
|
Thread Next