On Mon, May 1, 2017 at 8:52 PM, Eduardo Bustamante <dual...@gmail.com> wrote: > On Sat, Apr 29, 2017 at 8:56 PM, Adam Danischewski > <adam.danischew...@gmail.com> wrote: >> In the documentation you linked to it says: >> >> -f file >> True if file exists and is a regular file. >> >> The part of the documentation you cited states "Unless otherwise specified" >> - it is otherwise specified where it states "and is a regular file". It >> simply doesn't behave that way. > > Your not interpreting the document correctly. The test will first > resolve a chain of symbolic links, and operate on the target. There's > no exception mentioned for the -f primary. > > For the behavior you want, you need something like: > > test ! -h "$pathname" -a -f "$pathname" > > If you're still not convinced by the bash reference manual, then read > the POSIX specification for the test command: > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html > > "With the exception of the -h pathname and -L pathname primaries, if a > pathname argument is a symbolic link, test shall evaluate the > expression by resolving the symbolic link and using the file > referenced by the link."
I had not realized bug-bash wasn't CC'ed.