develooper Front page | perl.perl5.porters | Postings from March 2016

[perl #127663] Safety for -i option

Thread Previous | Thread Next
Jarkko Hietaniemi via RT
March 6, 2016 22:03
[perl #127663] Safety for -i option
Message ID:
On Sun Mar 06 07:15:04 2016, jhi wrote:
> > Can you supply us with: (a) the list of commands you invoked at the
> > command-line to get these results; (b) some idea of the size of the
> > file in question relative to the size of memory?
> >
> > Thank you very much.
> Also:
> (c) You said: "sed uses a temporary file to get the job and rename it.
> But it seems
> difficult to work considering portability. Many infrastructures (e.g.,
> gtk and qt) provide portable solution, but seems not to apply with
> perl."
> Can you elaborate on the portable solutions that gtk and qt provide?

I got the below email from

-- cut here --

Hi Jarkko,

My reply of bug #127663 is not appearing in the bug tracking system (I just replied the mail, sending to with subject “Re: [perl #127663] Safety for -i option”, and I have no idea why that does not work). I listed the comments below. Maybe you can post it.


Sed just uses rename() to replace the file with a temporary one, seems it is assuming a POSIX runtime, and this is POSIX safe. Gtk provides g_file_replace(), and Qt provides QSaveFile. Both are portable. We extensively tested these two implementations, and they are both safe in handling file overwrite. 

We believe that perl is an extremely portable software, and semantics of rename() may be different on other platforms, and this shall be handled with care (though I’m not an expert on portability).

Yanyan Jiang 蒋炎岩
Institute of Computer Software,
Dept. of Computer Science, Nanjing University

via perlbug:  queue: perl5 status: open

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About