Javscript (node), 19 bytes, 2 exit codes
Full program:
+process.argv[2]&&a
Function:
f=i=>i&&f(i)
process.argv
is an array that contains the path to the node executable, the path to the javascript file executed and the command line arguments. In this case, this will be either "1"
or "0"
. The string is converted to a number with the unary +
operator. If the number is zero the lazy &&
operator won't evaluate the right hand side, if the number is truthy (not zero), the right hand side of &&
is evaluated and an error is thrown because it's referencing an undefined variable, and the program exists with exit code 1.
The function expects the input as a number. If the input is truthy, the function calls itself, and crashes the node runtime with a stack overflow. If the input is 0, the lazy &&
operator returns 0 without evaluating the right hand side.