Bug 227706

Summary: document that file(1) succeeds when the file doesn't exist
Product: Documentation Reporter: Yuri Victorovich <yuri>
Component: Manual PagesAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Some People CC: 0mp, doc, lgfbsd
Priority: --- Keywords: easy, feature, needs-patch
Version: Latest   
Hardware: Any   
OS: Any   

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.