On 02/09/2015 02:00 PM, Cheng Rk wrote:
> 
> 
> To bug-bash@gnu.org:
> 
> 
> According this documentation `help test`, I am expecting it should return 
> false on anything other than a regular file,
> 
> -f FILE        True if file exists and is a regular file.
> 
> 
> but why it returned true on a symlink to a regular file?

Read the rest of the docs:

       Unless otherwise specified, primaries that operate on files
follow sym‐
       bolic links and operate on the target of the link, rather than
the link
       itself.

> 
> $ [ -f tmp/sym-link ] && echo true
> true

which  means tmp/sym-link resolved to a regular file.  You need test -h
to determine if you have a symlink.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to