develooper Front page | perl.perl5.porters | Postings from December 2008

Re: [perl #1154] -pi doesn't sanely handle write errors

Thread Previous | Thread Next
From:
Tom Christiansen
Date:
December 1, 2008 20:47
Subject:
Re: [perl #1154] -pi doesn't sanely handle write errors
Message ID:
25676.1228193192@chthon
>On Thu, Nov 27, 2008 at 12:52:08PM +0100, H.Merijn Brand wrote:
>> On Thu, 27 Nov 2008 03:28:50 -0800, Chip Salzenberg <chip@pobox.com> wrote:
>> >    -i.bak       - unsafe .bak
>> >    -i'*.bak'    - unsafe .bak
>> >    -i'**.bak'   - safe .bak
>>      -i'**'       - safe (using tmpfile), remove tmp on success

>Yup, it all fits.

>Code that wants to use safe renaming when possible and work elsewhere will
>have to check $], e.g.:

>  BEGIN { $^I = $] >= 5.11 ? '**.bak' : '*.bak' }

>or

>  #!/usr/bin/perl -pi~
>  BEGIN { $^I = '**~' if $] >= 5.11 }

>which doesn't quite match the simplicity of the alternatively proposed

>  ${^INPLACE_SAFE}++

>but I can certainly live with it.

>Objections?

Um, Chip, are people *really* claiming that fixing the -i output 
flush bug is something that would be "backwards incompatible", 
and thus prequire some notice that such a thing is desired?!?

If so, I'm boggling.  If not, I need to read more.

--tom

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About