STATUS_INVALID_ARGS = 2

The rest of the high-numbered exit codes are not values used by scripts
or builtins, they are internal to fish and come out of
the parser for example.

Prior to adding STATUS_INVALID_ARGS, builtins were usually exiting 2
if they had a special exit status for the situation of bad arguments.

Set it to 2.
This commit is contained in:
Aaron Gyes 2018-12-15 21:05:27 -08:00
parent b404b9392c
commit cf2b40040a

View file

@ -1078,9 +1078,13 @@ enum {
STATUS_CMD_OK = 0, STATUS_CMD_OK = 0,
/// The status code used for failure exit in a command (but not if the args were invalid). /// The status code used for failure exit in a command (but not if the args were invalid).
STATUS_CMD_ERROR = 1, STATUS_CMD_ERROR = 1,
/// The status code used for invalid arguments given to a command. This is distinct from valid
/// arguments that might result in a command failure. An invalid args condition is something
/// like an unrecognized flag, missing or too many arguments, an invalid integer, etc. But
STATUS_INVALID_ARGS = 2,
/// The status code used when a command was not found. /// The status code used when a command was not found.
STATUS_CMD_UNKNOWN = 127, STATUS_CMD_UNKNOWN = 127,
/// TODO: Figure out why we have two distinct failure codes for when an external command cannot /// TODO: Figure out why we have two distinct failure codes for when an external command cannot
/// be run. /// be run.
/// ///
@ -1095,10 +1099,6 @@ enum {
STATUS_ILLEGAL_CMD = 123, STATUS_ILLEGAL_CMD = 123,
/// The status code used when `read` is asked to consume too much data. /// The status code used when `read` is asked to consume too much data.
STATUS_READ_TOO_MUCH = 122, STATUS_READ_TOO_MUCH = 122,
/// The status code used for invalid arguments given to a command. This is distinct from valid
/// arguments that might result in a command failure. An invalid args condition is something
/// like an unrecognized flag, missing or too many arguments, an invalid integer, etc. But
STATUS_INVALID_ARGS = 121,
}; };
/* Normally casting an expression to void discards its value, but GCC /* Normally casting an expression to void discards its value, but GCC