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 | Thread Next
Robin Barker
September 23, 2003 10:09
RE: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlink s?
Message ID:
> 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).


-----Original Message-----
From: Yitzchak Scott-Thoennes []
Sent: 23 September 2003 18:04
To: Rafael Garcia-Suarez
Subject: Re: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles

On Tue, Sep 23, 2003 at 03:23:46PM +0200, 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
> > perl seems to be *seriously* mishandling symlinks with structures
> > "perl -pi -e s:foo:foo2: FILE".  If FILE is a symlink, perl doesn't
> > 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
> 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
> of your script :
>     BEGIN { @ARGV = map { -l $_ ? readlink : $_ } @ARGV; }

Needs to recurse if readlink returns a symlink.

This e-mail and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only.
If you are not a named addressee, you must not use, retain or
disclose such information.

NPL Management Ltd cannot guarantee that the e-mail or any
attachments are free from viruses.

NPL Management Ltd. Registered in England and Wales. No: 2937881
Registered Office: Teddington, Middlesex, United Kingdom TW11 0LW.

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