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.
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.
(In reply to lgfbsd from comment #1) I agree.
The EXIT STATUS section on current file(1) versions includes this: EXIT STATUS file will exit with 0 if the operation was successful or >0 if an error was encountered. The following errors cause diagnostic messages, but don't affect the program exit code (as POSIX requires), unless -E is specified: • A file cannot be found • There is no permission to read a file • The file type cannot be determined I think that covers the issue of this PR. Thanks for submitting it, it was fixed in the meantime. Sorry it took so long to close it.