TTY-Exit: terminal exit codes for humans and machines
github.com
github.com
* humans will always get way more information from a readable error message printed to stderr before exiting
* machines do not care about error details from third-party tools, apart from whether they are an input error (which can be blamed on the user, if they provided said input) or an internal error (including usage error) which is a bug and should be fixed by the calling program's developer
Indeed, the README has a lot of examples of using it in your child program, to report error, but no example of a parent program dealing with the reported error.
* It includes default user-friendly error messages for all the built-in exit codes. For example, the code 64 will print " "ERROR(64): Command line usage error" to stderr.
* Machines, e.i. programs that, for example, watch over an executable can decided based on the error code what to do. If the program is interrupted by Ctrl-C then the parent program can handle the situation gracefully.
I totally agree that an example of using an exit code in a parent program would be beneficial.
[1] https://manpage.me/index.cgi?apropos=0&q=sysexits&sektion=0&...
[1] http://tldp.org/LDP/abs/html/exitcodes.html [2] https://man.openbsd.org/signal.3
"A few programs exit with the following non-portable error codes. Do not use them."
I have included a method that helps you check if a code is reserved or not. For example, TTY::Exit.exit_reserved?(126) will return true as this is a status used by Bash to indicate a problem with executing a command.
Some random examples: Automated build systems like Jenkins typically use the exit status to decide if a build task has succeeded. `make` also uses exit codes to decide if a child task has succeeded and may abort the rest of the build based on that and return an exit code itself. A local mail delivery agent like maildrop may return different exit status depending on if it's a permanent or temporary failure and the mail transfer agent decides if it should retry the local delivery based on that. The exit status of a Docker of Kubernetes container is usually based on a process exit status too.