diff --git a/parse-options.c b/parse-options.c index 9ff9acaabf..79c56f32f9 100644 --- a/parse-options.c +++ b/parse-options.c @@ -330,6 +330,19 @@ static void parse_options_check(const struct option *opts) opts->long_name)) err |= optbug(opts, "uses feature " "not supported for dashless options"); + switch (opts->type) { + case OPTION_BOOLEAN: + case OPTION_BIT: + case OPTION_NEGBIT: + case OPTION_SET_INT: + case OPTION_SET_PTR: + case OPTION_NUMBER: + if ((opts->flags & PARSE_OPT_OPTARG) || + !(opts->flags & PARSE_OPT_NOARG)) + err |= optbug(opts, "should not accept an argument"); + default: + ; /* ok. (usually accepts an argument) */ + } } if (err) exit(128);