Exit 2
Usage error: bad options or arguments.
- Value
- 2
- Convention
- Shell and tool convention
Bash builtins return 2 when you misuse them, and GNU grep returns 2 for an actual error (unreadable file, bad regex) as opposed to 1 for no match. Many tools copy the habit for command-line mistakes. It is a convention, not a rule: 2 from an arbitrary program means "read its stderr".
What to check
cd --nope; echo $?Sources
Exit codes are conventions, not guarantees: a program can return any value from 0 to 255. Spot one that's wrong? Tell Rod.