Bug 227706 - document that file(1) succeeds when the file doesn't exist
Summary: document that file(1) succeeds when the file doesn't exist
Status: New
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: easy, feature, needs-patch
Depends on:
Blocks:
 
Reported: 2018-04-23 05:17 UTC by Yuri Victorovich
Modified: 2018-08-05 06:15 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer 2018-04-23 05:17:19 UTC
For nonexistent file file(1) returns zero on 11.1:
> $ /usr/bin/file /nonexistent
> /nonexistent: cannot open `/nonexistent' (No such file or directory)
> $ echo $?
> 0

Despite its manpage saying:
> RETURN CODE
>      file returns 0 on success, and non-zero on error.
Comment 1 lgfbsd 2018-04-23 14:37:53 UTC
I believe this is correct POSIX behavior:
"
    If the file named by the file operand does not exist, cannot be read, or the type of the file named by the file operand cannot be determined, this shall not be considered an error that affects the exit status.
"

An appropriate fix would be to add that text to our manual page.
Comment 2 Yuri Victorovich freebsd_committer 2018-04-23 15:43:05 UTC
(In reply to lgfbsd from comment #1)

I agree.