[math] Fail without arguments

See #4768.
This commit is contained in:
Fabian Homborg 2018-03-01 22:27:24 +01:00
parent b49e1d7703
commit 0da8022081
3 changed files with 8 additions and 0 deletions

View file

@ -186,5 +186,9 @@ int builtin_math(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
expression.append(arg);
}
if (expression.empty()) {
streams.err.append_format(BUILTIN_ERR_MIN_ARG_COUNT1, L"math", 1, 0);
return STATUS_CMD_ERROR;
}
return evaluate_expression(cmd, parser, streams, opts, expression);
}

View file

@ -22,3 +22,5 @@ math: Error: Too few arguments
math: Error: Too many arguments
'2 + 2 4'
^
math: Expected at least 1 args, got only 0
math: Expected at least 1 args, got only 0

View file

@ -29,3 +29,5 @@ not math 'ncr(1)'
not math 'max()'
not math 'sin()'
not math '2 + 2 4'
not math
not math -s 12