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