Project

General

Profile

Actions

Bug #10067

closed

File.file? misleading semantics & documentation for symbolic links

Bug #10067: File.file? misleading semantics & documentation for symbolic links

Added by robe (Michael Renner) over 11 years ago. Updated over 11 years ago.

Status:
Closed
Assignee:
Target version:
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
[ruby-core:63842]

Description

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 OR lstat 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.

Actions

Also available in: PDF Atom