Bug 453208 - perl -e file test misses broken symlinks
Summary: perl -e file test misses broken symlinks
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: perl
Version: 4.0
Hardware: i386
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Marcela Mašláňová
QA Contact: desktop-bugs@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-06-27 19:52 UTC by Steve
Modified: 2008-08-14 12:57 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-08-14 12:57:23 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Steve 2008-06-27 19:52:17 UTC
Description of problem:


Version-Release number of selected component (if applicable):
perl-5.8.5-16.RHEL4

How reproducible:
100%

Steps to Reproduce:
1. create a directory (mkdir /tmp/test1)
2. make a symlink to it (ln -s /tmp/test1 /tmp/linktest1)
3. move or delete the directory (mv /tmp/test1 /tmp/test1moved)
4. now the link is broken, so try running this script:

my $filename = "/tmp/linktest1";
my $directory = "/tmp";

chomp($filename);
if( -e $filename)
{
    `/bin/rm -f $filename`;
}

chomp($directory);
if( -d $directory)
{
    `/bin/ln -s /tmp/test1moved $filename`;
}



Actual results:
The script gives this for output:

/bin/ln: `/tmp/linktest1': File exists

Basically, it does not enter the first if statement, and the broken link is 
not deleted.  However, if you replace the "-e" test with the "-l" test, the 
broken link is deleted.  

Expected results:

I would expect that the -e flag with see the broken link as a file, which 
would then cause it to be deleted.  Note that the above test program does work 
fine if the link is not broken.  

Additional info:  Obviously, I don't really need the rm command inside of the 
if statement, because it doesn't really matter if the file exists or not.  
However, I noticed that the -e flag didn't work as I expected it to, and I 
thought someone else might run into it unexpectedly on something more 
important.  Let me know if you need more info.

Comment 1 Marcela Mašláňová 2008-08-14 12:57:23 UTC
This must be a conventional behaviour. If you try the same with bash, it ends the same way.


Note You need to log in before you can comment on or make changes to this bug.