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

Re: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlinks?

From:
Yitzchak Scott-Thoennes
Date:
September 23, 2003 10:04
Subject:
Re: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlinks?
Message ID:
20030923170416.GA3440@efn.org
On Tue, Sep 23, 2003 at 03:23:46PM +0200, Rafael Garcia-Suarez <raphel.garcia-suarez@hexaflux.com> wrote:
> Pekka Savola (via RT) wrote:
> > On Red Hat Linux 7.3 and 9 (perl 5.6.1 and 5.8, respectively), at least, 
> > perl seems to be *seriously* mishandling symlinks with structures like 
> > "perl -pi -e s:foo:foo2: FILE".  If FILE is a symlink, perl doesn't follow 
> > it, causing a symlink being converted to a file in the directory where the 
> > symlink resided in.
> 
> At first sight, I don't think perl should transparently follow symlinks.
> That's not what I expect it to do. However this can be argued.

Perhaps at least a warning for -i on a symlink?

> Note that you can force perl to follow symlinks by inserting at the top
> of your script :
> 
>     BEGIN { @ARGV = map { -l $_ ? readlink : $_ } @ARGV; }

Needs to recurse if readlink returns a symlink.



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