develooper Front page | perl.perl5.porters | Postings from September 2003

RE: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlink s?

Thread Previous
From:
Aaron Sherman
Date:
September 23, 2003 11:30
Subject:
RE: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlink s?
Message ID:
1064341824.1203.761.camel@localhost.localdomain
On Tue, 2003-09-23 at 13:08, Robin Barker wrote:
> > Needs to recurse if readlink returns a symlink.
> And to resolve the output of readlink relative to the link's 
> directory (unless readlink returns an absolute filename).

No, that way lies dragons. Perl should have some switch that at the
C-level causes the change from current behavior in doio.c (around like
811 in 5.8.0):

* Rename old name to new name
* Open STDOUT filehandle on old name for create/writing
* Open ARGV filehandle on new name for reading

to the more complex:

* Copy old file to new name
* Replicate ownership and permissions from old file to new file (if
possible)
* Open STDOUT filehandle on old name for create/truncate/writing
* Open ARGV filehandle on new name for reading

There are sound technical reasons to do either one, but I *would* argue
that the average joe on the street expects the second one by default....

-- 
Aaron Sherman <ajs@ajs.com>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


Thread Previous


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