Fix status code when bad command name is entered

This commit fixes a bug which causes that

   fish -c ')'; echo $status

("Illegal command name" error) returns 0. This is inconsistent with
e.g. when trying to run non-existent command:

   fish -c 'invalid-command'; echo $status

("Unknown command" error) which correctly returns 127.

A new status code,

    STATUS_ILLEGAL_CMD = 123

is introduced - which is returned whenever the 'Illegal command name *'
message is printed.

This commit also adds a test which checks if valid commands return 0,
while commands with illegal name return status code 123.

Fixes #3606.
This commit is contained in:
Radomír Bosák
2016-12-03 17:15:29 +01:00
committed by ridiculousfish
parent bf53f39cdd
commit 254762f30f
4 changed files with 45 additions and 0 deletions

View File

@@ -832,6 +832,7 @@ parse_execution_result_t parse_execution_context_t::populate_plain_process(
bool expanded = expand_one(cmd, EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES, NULL);
if (!expanded) {
report_error(statement, ILLEGAL_CMD_ERR_MSG, cmd.c_str());
proc_set_last_status(STATUS_ILLEGAL_CMD);
return parse_execution_errored;
}