Chapter 1: The machine

Programs say a lot in words. They also hand back one number, and that number is what machines trust.

Exit code

Also called Exit status, Return code, $?

The number a program hands back when it ends. 0 means it went fine, and anything else means it didn't. You rarely see it, but the shell keeps the latest one in $?. Automatic checks in software rest on this.

An agent, or any automatic check, decides whether to carry on from this number, not from the words on screen. A program can print success and exit 1, or print nothing and exit 0. When you want proof that something passed, ask for the code.

Say it to your agent

“Run bun test, then echo $? on its own line, with nothing piped. Show me the number. Don't tell me the tests passed unless it is 0.”

The workshop

Name a word, or describe what you mean in everyday language.