mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
[math] Return STATUS_CMD_ERROR when an error occured
This commit is contained in:
parent
18bc2b0f4a
commit
0d9123ec91
1 changed files with 3 additions and 1 deletions
|
@ -134,6 +134,7 @@ static int evaluate_expression(const wchar_t *cmd, parser_t &parser, io_streams_
|
|||
math_cmd_opts_t &opts, wcstring &expression) {
|
||||
UNUSED(parser);
|
||||
|
||||
int retval = STATUS_CMD_OK;
|
||||
te_error_t error;
|
||||
char *narrow_str = wcs2str(expression);
|
||||
// Switch locale while computing stuff.
|
||||
|
@ -155,10 +156,11 @@ static int evaluate_expression(const wchar_t *cmd, parser_t &parser, io_streams_
|
|||
streams.err.append_format(L"%ls: Error: %ls\n", cmd, math_describe_error(error).c_str());
|
||||
streams.err.append_format(L"'%ls'\n", expression.c_str());
|
||||
streams.err.append_format(L"%*lc^\n", error.position - 1, L' ');
|
||||
retval = STATUS_CMD_ERROR;
|
||||
}
|
||||
free(narrow_str);
|
||||
free(saved_locale);
|
||||
return STATUS_CMD_OK;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// The math builtin evaluates math expressions.
|
||||
|
|
Loading…
Reference in a new issue