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

[perl #127663] Safety for -i option

Thread Previous | Thread Next
From:
Jarkko Hietaniemi via RT
Date:
March 6, 2016 22:03
Subject:
[perl #127663] Safety for -i option
Message ID:
rt-4.0.18-23221-1457301812-873.127663-15-0@perl.org
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 jiangyy@outlook.com:

-- cut here --

Hi Jarkko,

My reply of bug #127663 is not appearing in the bug tracking system (I just replied the mail, sending to perlbug-followup@perl.org 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).

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



---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=127663

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