another step in fixing issue #3985

This changes all of the builtins to behave like `string` to return
STATUS_INVALID_ARGS (121) if the args passed to the command don't make
sense. Also change several of the builtins to use the existing symbols
(e.g., STATUS_CMD_OK and STATUS_CMD_ERROR) rather than hardcoded "0"
and "1" for consistency and to make it easier to find such values in
the future.

Fixes #3985
This commit is contained in:
Kurtis Rader
2017-05-04 21:35:41 -07:00
parent be2b6bfdc9
commit e6e1805c5f
13 changed files with 163 additions and 169 deletions

View File

@@ -591,7 +591,7 @@ bool combining_expression::evaluate(wcstring_list_t &errors) {
}
errors.push_back(format_string(L"Unknown token type in %s", __func__));
return STATUS_CMD_ERROR;
return STATUS_INVALID_ARGS;
}
bool parenthetical_expression::evaluate(wcstring_list_t &errors) {
@@ -741,7 +741,7 @@ int builtin_test(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
using namespace test_expressions;
// The first argument should be the name of the command ('test').
if (!argv[0]) return STATUS_CMD_ERROR;
if (!argv[0]) return STATUS_INVALID_ARGS;
// Whether we are invoked with bracket '[' or not.
wchar_t *program_name = argv[0];
@@ -758,7 +758,7 @@ int builtin_test(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
argc--;
} else {
streams.err.append(L"[: the last argument must be ']'\n");
return STATUS_CMD_ERROR;
return STATUS_INVALID_ARGS;
}
}