mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 14:01:20 -03:00
Make test error when number is invalid nicer
This would print the default "Argument is invalid" error string, which is *true* but not super obvious, because `test` doesn't always perform numeric conversion, and that's the bit that failed here.
This commit is contained in:
@@ -716,6 +716,8 @@ static bool parse_number(const wcstring &arg, number_t *number, wcstring_list_t
|
||||
errors.push_back(_(L"Not a number"));
|
||||
} else if (std::isinf(floating)) {
|
||||
errors.push_back(_(L"Number is infinite"));
|
||||
} else if (errno == EINVAL) {
|
||||
errors.push_back(format_string(L"Argument is not a number: '%ls'", argcs));
|
||||
} else {
|
||||
errors.push_back(format_string(L"%s: '%ls'", std::strerror(errno), argcs));
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ function t
|
||||
end
|
||||
|
||||
t foo
|
||||
# CHECKERR: Invalid argument: 'foo'
|
||||
# CHECKERR: Argument is not a number: 'foo'
|
||||
# CHECKERR: {{.*}}test.fish (line {{\d+}}):
|
||||
# CHECKERR: test $argv[1] -eq 5
|
||||
# CHECKERR: ^
|
||||
|
||||
Reference in New Issue
Block a user