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

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

From:
Pekka Savola
Date:
September 23, 2003 06:02
Subject:
[perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlinks?
Message ID:
rt-24000-65009.0.252767139854342@rt.perl.org
# New Ticket Created by  Pekka Savola 
# Please include the string:  [perl #24000]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=24000 >


Hi,

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.

Smells very much like a bug..?

The behaviour should be apparent from below:

pekkas: /home/pekkas/perl$ echo test > unf2
pekkas: /home/pekkas/perl$ ln -s unf2 unf
pekkas: /home/pekkas/perl$ ls -la unf*
lrwxrwxrwx    1 pekkas   pekkas          4 Sep 23 14:15 unf -> unf2
-rw-rw-r--    1 pekkas   pekkas          5 Sep 23 14:14 unf2
pekkas: /home/pekkas/perl$ perl -pi -e s:test:testx: unf
pekkas: /home/pekkas/perl$ ls -la unf*
-rw-rw-r--    1 pekkas   pekkas          6 Sep 23 14:15 unf
-rw-rw-r--    1 pekkas   pekkas          5 Sep 23 14:14 unf2
pekkas: /home/pekkas/perl$ more unf*
::::::::::::::
unf
::::::::::::::
testx
::::::::::::::
unf2
::::::::::::::
test

-- 
Pekka Savola                 "You each name yourselves king, yet the
Netcore Oy                    kingdom bleeds."
Systems. Networks. Security. -- George R.R. Martin: A Clash of Kings





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