Skip to main content
Add a comparison to `C`, and where shell differs.
Source Link
ctrl-alt-delor
  • 28.8k
  • 11
  • 66
  • 113

The shell is not C. In C 0 is false, everything else is true. In the shell 0 is true/success, everything else is false. This is because there are many ways to fail, but one way to succeed.

Specifically from the info page, of test.

Exit status:

 0 if the expression is true,
 1 if the expression is false,
 2 if an error occurred.

from the info page

Exit status:

 0 if the expression is true,
 1 if the expression is false,
 2 if an error occurred.

The shell is not C. In C 0 is false, everything else is true. In the shell 0 is true/success, everything else is false. This is because there are many ways to fail, but one way to succeed.

Specifically from the info page, of test.

Exit status:

 0 if the expression is true,
 1 if the expression is false,
 2 if an error occurred.
Source Link
ctrl-alt-delor
  • 28.8k
  • 11
  • 66
  • 113

from the info page

Exit status:

 0 if the expression is true,
 1 if the expression is false,
 2 if an error occurred.