|
58 | 58 | # |
59 | 59 | # * 3-63 are for a program-specific exit codes. |
60 | 60 | # |
61 | | -# * 64-78 are based on sysexits documentation from the 1980's. |
| 61 | +# * 64-78 are based on BSD sysexits <https://man.openbsd.org/sysexits.3> |
62 | 62 | # |
63 | 63 | # * 80-119 are SixArm conventions that we find useful in many programs. |
64 | 64 | # |
65 | | -# Many POSIX shells use exit codes 126 and 127 to signal specific error status: |
| 65 | +# Many shells use exit codes 126-128 to signal specific error status: |
66 | 66 | # |
67 | | -# * 126 is for the shell and indicates command found but not executable. |
| 67 | +# * 126 is for the shell and indicates command found but is not executable. |
68 | 68 | # |
69 | 69 | # * 127 is for the shell and indicate command not found. |
70 | 70 | # |
71 | | -# Many POSIX shells use exit codes above 128 in their $? representation of the |
72 | | -# exit status to encode the signal number of a process being killed. |
| 71 | +# * 128 is for invalid argument to exit. |
73 | 72 | # |
74 | | -# The pre-defined exit codes from sysexits can be used, so the caller of the |
75 | | -# process can get a rough estimation about the failure class without looking up |
76 | | -# the source code. |
| 73 | +# Many shells use exit codes above 128 in their $? representation of the exit |
| 74 | +# status to encode the signal number of a process being killed. |
77 | 75 | # |
78 | | -# See https://man.openbsd.org/sysexits.3 |
| 76 | +# * 128+n means fatal error signal "n" |
79 | 77 | # |
80 | | -# We recommend: |
| 78 | +# * Example: 130 means terminated by ctrl-C (because ctrl-c is signal 2) |
| 79 | +# |
| 80 | +# * Example: 137 means terminated by kill -9 (because 128 + 9 = 137) |
| 81 | +# |
| 82 | +# Finally, the highest exit code: |
| 83 | +# |
| 84 | +# * 255 Exit status out of range (exit takes integer args 0-255) |
| 85 | +# |
| 86 | +# Be aware that on some shells, ut of range exit values can result in unexpected |
| 87 | +# exit codes. An exit value greater than 255 returns an exit code modulo 256. |
| 88 | +# |
| 89 | +# * Example: exit 257 becomes exit 1 (because 257 % 256 = 1) |
| 90 | +# |
| 91 | +# * Caution: exit 256 becomes exit 0, which probably isn't what you want. |
| 92 | +# |
| 93 | +# For some typical needs that we encounter, we can suggest these: |
81 | 94 | # |
82 | 95 | # * Authentication issues: exit $EXIT_NOUSER |
83 | 96 | # |
@@ -380,6 +393,22 @@ EXIT_COMMAND_FOUND_BUT_NOT_EXECUTABLE=126 |
380 | 393 | # |
381 | 394 | EXIT_COMMAND_NOT_FOUND=127 |
382 | 395 |
|
| 396 | +# Exit code invalid |
| 397 | +# |
| 398 | +# The exit code is invalid. |
| 399 | +# |
| 400 | +# Compare EXIT_CODE_OUT_OF_RANGE=255 |
| 401 | +# |
| 402 | +EXIT_CODE_INVALID=128 |
| 403 | + |
| 404 | +# Exit code out of range |
| 405 | +# |
| 406 | +# The exit code is out of range i.e. not in 0-255. |
| 407 | +# |
| 408 | +# Compare EXIT_CODE_INVALID=128 |
| 409 | +# |
| 410 | +EXIT_CODE_INVALID=128 |
| 411 | + |
383 | 412 | ## |
384 | 413 | # Input/output helpers |
385 | 414 | ## |
@@ -967,7 +996,7 @@ touch_format() { |
967 | 996 |
|
968 | 997 | # select_character_class: get a string's characters that match a class, with optional offset and length. |
969 | 998 | # |
970 | | -# Syntax: |
| 999 | +# Syntax: |
971 | 1000 | # ``` |
972 | 1001 | # select_character_class <string> <class> [offset [length]] |
973 | 1002 | # ``` |
|
0 commit comments