mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 15:01:16 -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"));
|
errors.push_back(_(L"Not a number"));
|
||||||
} else if (std::isinf(floating)) {
|
} else if (std::isinf(floating)) {
|
||||||
errors.push_back(_(L"Number is infinite"));
|
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 {
|
} else {
|
||||||
errors.push_back(format_string(L"%s: '%ls'", std::strerror(errno), argcs));
|
errors.push_back(format_string(L"%s: '%ls'", std::strerror(errno), argcs));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ function t
|
|||||||
end
|
end
|
||||||
|
|
||||||
t foo
|
t foo
|
||||||
# CHECKERR: Invalid argument: 'foo'
|
# CHECKERR: Argument is not a number: 'foo'
|
||||||
# CHECKERR: {{.*}}test.fish (line {{\d+}}):
|
# CHECKERR: {{.*}}test.fish (line {{\d+}}):
|
||||||
# CHECKERR: test $argv[1] -eq 5
|
# CHECKERR: test $argv[1] -eq 5
|
||||||
# CHECKERR: ^
|
# CHECKERR: ^
|
||||||
|
|||||||
Reference in New Issue
Block a user