On macOS 10.14, using whatis
on a command that is not installed prints 'command': nothing appropriate
as is expected. But returns 0 instead of an error code, which I believe is expected behavior. It is also not consistent with man
, which returns 1 after no results. Additionally, whatis
prints to stdout, while man
prints to stderr.
This is different than Linux, which returns an error code, and prints to stderr.
macOS:
$ whatis abc; echo $?
abc: nothing appropriate
0
$ man abc; echo $?
No manual entry for abc
1
$ whatis abc 2>/dev/null
abc: nothing appropriate
$ man abc 2>/dev/null
Linux (Ubuntu):
$ whatis abc; echo $?
abc: nothing appropriate.
16
$ man abc; echo $?
No manual entry for abc
16
$ whatis abc 2>/dev/null
$ man abc 2>/dev/null
I believe whatis
should not return 0 when it fails to find a description of the command, and should have behavior consistent with man
Note: I noticed this because I'm writing a program that relies on this functionality
Edit: apropos
has the same behavior as whatis