Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exit with code, stdio & stderr

Overview

Minimalistic command-line utility that terminates immediately after starting, while controlling the exit code, standard output (stdout) message and standard error (stderr) message in a single invocation.

Usage

exit-with [code] [msg-1] [msg-2] 
  • code - optional exit code, default is 0 (zero).
  • msg-1 - optional message printed to:
    • stdout when code is zero,
    • stderr when code is nonzero.
  • msg-2 - optional message printed to:
    • stderr when code is zero,
    • stdout when code is nonzero.

Important

Please note, that the destination where msg-1 and msg-2 are printed depends on the value of code.

Tip

Because of the specific usage of this application, the only outputs are an exit code, a stdout message, and a stderr message. There are no additional options such as displaying version information, displaying help text, or handling invalid arguments with error messages.

Examples

codestdoutstderrcommand
0--exit-with
0--exit-with 0
0hello-exit-with 0 hello
0helloworldexit-with 0 hello world
0-worldexit-with 0 “” world
1--exit-with 1
1-helloexit-with 1 hello
1worldhelloexit-with 1 hello world
1world-exit-with 1 “” world