[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Does [ -f FILE ] have a bug on testing a symlink ?
From: |
Eric Blake |
Subject: |
Re: Does [ -f FILE ] have a bug on testing a symlink ? |
Date: |
Mon, 09 Feb 2015 14:44:29 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
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
signature.asc
Description: OpenPGP digital signature
- Does [ -f FILE ] have a bug on testing a symlink ?, Cheng Rk, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Chet Ramey, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Ken Irving, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Evan Gates, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?,
Eric Blake <=
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Bob Proulx, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Andreas Schwab, 2015/02/09
Re: Does [ -f FILE ] have a bug on testing a symlink ?, Greg Wooledge, 2015/02/09