3 ms·
The Advanced Bash-Scripting Guide also has some (IMO) good advice, with a footnoted mention of sysexits.h: https://tldp.org/LDP/abs/html/exitcodes.html https://
by npongratz 5y ago
The Advanced Bash-Scripting Guide also has some (IMO) good advice, with a footnoted mention of sysexits.h: https://tldp.org/LDP/abs/html/exitcodes.html https://tldp.org/LDP/abs/html/exitcodes.html
> The author of this document proposes restricting user-defined exit codes to the range 64 - 113 (in addition to 0, for success), to conform with the C/C++ standard. This would allot 50 valid codes, and make troubleshooting scripts more straightforward.[2]
> ...
> [2] An update of /usr/include/sysexits.h allocates previously unused exit codes from 64 - 78. It may be anticipated that the range of unallotted exit codes will be further restricted in the future. The author of this document will not do fixups on the scripting examples to conform to the changing standard. This should not cause any problems, since there is no overlap or conflict in usage of exit codes between compiled C/C++ binaries and shell scripts.
- _kst_ 5y ago> The author of this document proposes restricting user-defined exit codes to the range 64 - 113 (in addition to 0, for success), to conform with the C/C++ standard. The C and C++ standards don't say anything that suggests reserving the range 64-113. Here's what the C standard says: > If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. If the value of status is EXIT_FAILURE, an implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned is implementation-defined. C++ inherits C's specification. EXIT_SUCCESS is (almost?) always defined as 0. EXIT_FAILURE is usually defined as 1 (but not on OpenVMS, where the OS defines 1 as a form of success). The restriction to 8-bit values is POSIX, not C or C++.