You need to decide if the File?-methods offer statORlstat semantic, change it and document it accordingly.
The current documentation and implementation behavior is especially confusing since the POSIX standard states that the type of a file can be either a regular file OR a symlink, not both at the same time.
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.
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.
Oh my, just double-checked, Python and Perl have implemented the same behaviour as test(1), along with Ruby.
The big difference being the wording of the documentation. The test man page explicitly states:
True if pathname resolves to an existing directory entry for a [..]
as well as the paragraph you quoted.
I guess clarifying that in the File documentation is warranted as well as pointing out that people are strongly advised to use lstat if they want consistent behaviour.
I personally would go as far and ditch the test(1) semantics and stick to querying lstat() by default, but that's just me and will probably break lots of things ;)
file.c: [DOC] Clarify how File.file? handles symbolic links. Also
cleaned up the rdoc style for this method, more to follow.
Originally reported by Michael Renner [Bug #10067]