bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this a bug in [[ -f ]]?


From: Eric Blake
Subject: Re: Is this a bug in [[ -f ]]?
Date: Thu, 18 Aug 2011 10:40:35 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11

On 08/18/2011 10:35 AM, Steven W. Orr wrote:
I have a symlink file and if if I test it I get success status with -f.

831 > ls -l errio err
lrwxrwxrwx. 1 sorr fc 5 Aug 18 08:48 err -> errio
-rw-rw-r--. 1 sorr fc 3816 Aug 18 08:48 errio
832 > [[ -f errio ]]
833 > echo $? # Good answer
0
*834 > [[ -h errio ]]
835 > echo $? # Good answer
1
*836 > [[ -f err ]]
837 > echo $? # BAD answer
0

Good answer. The man page says that symlinks are dereferenced for most tests (-h and -L being the exceptions). Since err is a symlink that resolves, -f err is true.


Is this a bug? Is there a workaround? Am I doing something wrong?

Merely that you were expecting -f to mean 'file and not symlink' rather than what was documented of 'file or symlink to file'.

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]