From: jared@... Date: 2014-07-19T04:23:43+00:00 Subject: [ruby-core:63854] [ruby-trunk - Bug #10067] File.file? misleading semantics & documentation for symbolic links Issue #10067 has been updated by Jared Beck. I can confirm that `test -f` and `File.file?` seem to have the same return values in this example: ln -s link file ruby -e 'puts File.file?("link")' false test -f link; echo $? 1 touch file ruby -e 'puts File.file?("link")' true test -f link; echo $? 0 Though, I'm using ruby 2.1.2 on mac os 10.9.4, so your mileage may vary :) ruby --version ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0] ---------------------------------------- Bug #10067: File.file? misleading semantics & documentation for symbolic links https://bugs.ruby-lang.org/issues/10067#change-47884 * Author: Michael Renner * Status: Open * Priority: Normal * Assignee: Zachary Scott * Category: doc * Target version: current: 2.2.0 * ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- The documentation for ``File.file?`` states: "Returns true if the named file exists and is a regular file." When trying that out I get the following results: ~~~ % /usr/bin/stat link File: `link' -> `file' Size: 4 Blocks: 0 IO Block: 4096 symbolic link Device: 16h/22d Inode: 2804357 Links: 1 Access: (0777/lrwxrwxrwx) Uid: ( 1000/ robe) Gid: ( 1000/ robe) Access: 2014-07-19 01:01:51.514979670 +0200 Modify: 2014-07-19 01:01:50.799975936 +0200 Change: 2014-07-19 01:01:50.799975936 +0200 Birth: - % ruby -e "puts File.file?('link')" false % ruby -e "puts File.symlink?('link')" true % touch file % ruby -e "puts File.file?('link')" true % ruby -e "puts File.symlink?('link')" true % ~~~ which is entirely not what one would expect. You need to decide if the ``File`` ``?``-methods offer [stat](http://pubs.opengroup.org/onlinepubs/009695399/functions/stat.html) _OR_ [lstat](http://pubs.opengroup.org/onlinepubs/009695399/functions/lstat.html) semantic, change it and document it accordingly. The current documentation and implementation behavior is especially confusing since the [POSIX standard](http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html) states that the type of a file can be either a regular file _OR_ a symlink, not both at the same time. -- https://bugs.ruby-lang.org/