more wgetopt_long() normalization

This commit is contained in:
Kurtis Rader
2017-06-29 21:49:57 -07:00
parent bf2a9f3835
commit dd191a9d4b
15 changed files with 83 additions and 25 deletions

View File

@@ -37,7 +37,7 @@ struct functions_cmd_opts_t {
bool verbose = false;
wchar_t *description = NULL;
};
static const wchar_t *short_options = L"Dacehnqv";
static const wchar_t *short_options = L":Dacehnqv";
static const struct woption long_options[] = {
{L"erase", no_argument, NULL, 'e'}, {L"description", required_argument, NULL, 'd'},
{L"names", no_argument, NULL, 'n'}, {L"all", no_argument, NULL, 'a'},
@@ -88,6 +88,10 @@ static int parse_cmd_opts(functions_cmd_opts_t &opts, int *optind, //!OCLINT(hi
opts.copy = true;
break;
}
case ':': {
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, argv[w.woptind - 1]);
return STATUS_INVALID_ARGS;
}
case '?': {
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
return STATUS_INVALID_ARGS;