mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
parent
0e707b88f0
commit
fdf398e435
@ -179,7 +179,7 @@ void builtin_unknown_option(parser_t &parser, io_streams_t &streams, const wchar
|
|||||||
/// Perform error reporting for encounter with missing argument.
|
/// Perform error reporting for encounter with missing argument.
|
||||||
void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wchar_t *cmd,
|
void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wchar_t *cmd,
|
||||||
const wchar_t *opt) {
|
const wchar_t *opt) {
|
||||||
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, opt);
|
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, opt + std::wcslen(opt) - 1);
|
||||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,7 +550,8 @@ static int argparse_parse_flags(parser_t &parser, argparse_cmd_opts_t &opts,
|
|||||||
wgetopter_t w;
|
wgetopter_t w;
|
||||||
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, &long_idx)) != -1) {
|
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, &long_idx)) != -1) {
|
||||||
if (opt == ':') {
|
if (opt == ':') {
|
||||||
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, argv[w.woptind - 1]);
|
const wchar_t *arg = argv[w.woptind - 1];
|
||||||
|
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, arg + std::wcslen(arg) - 1);
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
} else if (opt == '?') {
|
} else if (opt == '?') {
|
||||||
// It's not a recognized flag. See if it's an implicit int flag.
|
// It's not a recognized flag. See if it's an implicit int flag.
|
||||||
|
@ -458,7 +458,8 @@ static int parse_opts(options_t *opts, int *optind, int n_req_args, int argc, wc
|
|||||||
int retval = fn->second(argv, parser, streams, w, opts);
|
int retval = fn->second(argv, parser, streams, w, opts);
|
||||||
if (retval != STATUS_CMD_OK) return retval;
|
if (retval != STATUS_CMD_OK) return retval;
|
||||||
} else if (opt == ':') {
|
} else if (opt == ':') {
|
||||||
string_error(streams, BUILTIN_ERR_MISSING, cmd, argv[w.woptind - 1]);
|
const wchar_t *arg = argv[w.woptind - 1];
|
||||||
|
string_error(streams, BUILTIN_ERR_MISSING, cmd, arg + std::wcslen(arg) - 1);
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
} else if (opt == '?') {
|
} else if (opt == '?') {
|
||||||
string_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
string_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||||
|
@ -305,5 +305,5 @@ begin
|
|||||||
end
|
end
|
||||||
|
|
||||||
# #6483 - error messages for missing arguments
|
# #6483 - error messages for missing arguments
|
||||||
argparse -n foo r/required= -- foo -r
|
argparse -n foo q r/required= -- foo -qr
|
||||||
# CHECKERR: foo: Expected argument for option -r
|
# CHECKERR: foo: Expected argument for option r
|
||||||
|
@ -330,7 +330,7 @@ echo "stdin" | string repeat -n1 "and arg"; and echo "exit 0"
|
|||||||
# CHECKERR: string repeat: Too many arguments
|
# CHECKERR: string repeat: Too many arguments
|
||||||
|
|
||||||
string repeat -n; and echo "exit 0"
|
string repeat -n; and echo "exit 0"
|
||||||
# CHECKERR: string repeat: Expected argument for option -n
|
# CHECKERR: string repeat: Expected argument for option n
|
||||||
|
|
||||||
# FIXME: Also triggers usage
|
# FIXME: Also triggers usage
|
||||||
# string repeat -l fakearg
|
# string repeat -l fakearg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user