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

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

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
September 27, 2012 18:59
Subject:
[perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlinks?
Message ID:
rt-3.6.HEAD-11172-1348797563-578.24000-15-0@perl.org
On Tue Sep 23 09:39:38 2003, pekkas@netcore.fi wrote:
> On 23 Sep 2003, Rafael Garcia-Suarez 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.
> 
> I have to really, really disagree with you here.  Consider what the
> script
> is supposed to be doing: "replace test with textx in the file".  How
> is
> this different e.g. from firing up *any* text editor and making that
> replacement?  When I make operations on the symlink, I certainly
> _expect_
> them to be done at the file the symlink points to.  This perl
> behaviour
> breaks the principle of least surprise badly, IMHO.
> 
> > Note that you can force perl to follow symlinks by inserting at the
> top
> > of your script :
> >
> >     BEGIN { @ARGV = map { -l $_ ? readlink : $_ } @ARGV; }
> >
> > [You could even put this in a FollowSymlinks.pm file, to be loaded
> via
> > "PERL5OPT=-IFollowSymlinks".]
> 
> .. right but this is really a bit too complex, and won't help those
> whose
> expectations are broken by current behaviour.  However, I could
> imagine
> that a perl command-line argument could be possible, even though not
> really the optimal way to solve the problem.
> 

This ticket has not attracted comments in about nine years.  From
skimming the discussion, my impression is that Rafael thought no change
in Perl's then current behavior was necessary -- but the OP wasn't
satisfied with that.

Could someone give this ticket some attention and make a recommendation?

Thank you very much.
Jim Keenan


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

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