Linus Torvalds <torvalds@linux-foundation.org> writes:
With this on top of Pierre's series, and adding PARSE_OPT_SKIP_UNKNOWN to
the obvious place in your patch, "blame --since=April -b Makefile" would
work.
-- >8 --
Subject: [PATCH] parse-options: PARSE_OPT_SKIP_UNKNOWN
---
parse-options.c | 14 ++++++++++----
parse-options.h | 1 +
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/parse-options.c b/parse-options.c
index 71a8056..9f1eb65 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -341,20 +341,26 @@ int parse_options(int argc, const char **argv, const struct option *options,
struct parse_opt_ctx_t ctx;
parse_options_start(&ctx, argc, argv, flags);
+
+ again:
switch (parse_options_step(&ctx, options, usagestr)) {
case PARSE_OPT_HELP:
exit(129);
case PARSE_OPT_DONE:
break;
default: /* PARSE_OPT_UNKNOWN */
- if (ctx.argv[0][1] == '-') {
+ if (flags & PARSE_OPT_KEEP_UNKNOWN) {
+ ctx.out[ctx.cpidx++] = ctx.argv[0];
+ ctx.argc--;
+ ctx.argv++;
+ goto again;
+ }
+ if (ctx.argv[0][1] == '-')
error("unknown option `%s'", ctx.argv[0] + 2);
- } else {
+ else
error("unknown switch `%c'", *ctx.opt);
- }
usage_with_options(usagestr, options);
}
-
return parse_options_end(&ctx);
}
diff --git a/parse-options.h b/parse-options.h
index 403794f..30fbf7e 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -22,6 +22,7 @@ enum parse_opt_type {
enum parse_opt_flags {
PARSE_OPT_KEEP_DASHDASH = 1,
PARSE_OPT_STOP_AT_NON_OPTION = 2,
+ PARSE_OPT_KEEP_UNKNOWN = 4,
};
enum parse_opt_option_flags {
--
1.5.6.49.g112db
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html