bug-bash
[Top][All Lists]
Advanced

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

Re: Does [ -f FILE ] have a bug on testing a symlink ?


From: Ken Irving
Subject: Re: Does [ -f FILE ] have a bug on testing a symlink ?
Date: Mon, 9 Feb 2015 12:54:31 -0900
User-agent: Mutt/1.5.20 (2009-06-14)

On Mon, Feb 09, 2015 at 09:00:12PM +0000, 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?
> 
> $ [ -f tmp/sym-link ] && echo true
> true

Symlinks are transparent for most purposes, and in your case the test
is against the file pointed to by the symlink.  If you want to test the
symlink itself you can use the -h or -L test operators.



reply via email to

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