Exit Status and test

1 / 12

Every command that finishes leaves behind a number: 0 if it succeeded, non-zero if it didn't. That number is the only thing the shell knows about whether the last thing you did worked, and it is the foundation every conditional in this lesson is built on.

Zero meaning success is backwards from most languages, and there is a reason: there is exactly one way to succeed, and many ways to fail. Non-zero values let a program say which failure.

Finish →