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 ebl...@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org