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: Geir Hauge
Subject: Re: Does [ -f FILE ] have a bug on testing a symlink ?
Date: Mon, 9 Feb 2015 22:42:40 +0100

2015-02-09 22:00 GMT+01:00 Cheng Rk <crquan@ymail.com>:
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

The manual has this in addition:

«Unless otherwise specified, primaries that operate on files follow symbolic links and operate on the target of the link, rather than the link itself.» 

http://www.gnu.org/software/bash/manual/bashref.html#Bash-Conditional-Expressions

Probably wouldn't hurt to include that in the help text for the test builtin as well.

--
Geir Hauge

reply via email to

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