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
From:
Robin Barker
Date:
September 23, 2003 10:09
Subject:
RE: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlink s?
Message ID:
533D273D4014D411AB1D00062938C4D90404668E@hotel.npl.co.uk
> 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).

Robin

-----Original Message-----
From: Yitzchak Scott-Thoennes [mailto:sthoenna@efn.org]
Sent: 23 September 2003 18:04
To: Rafael Garcia-Suarez
Cc: perl5-porters@perl.org
Subject: Re: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles
symlinks?


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.

-------------------------------------------------------------------
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


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