This new option tells parse-options not to ignore argv[0]. This is useful when argv cames from split_cmdline(), as in that case argv[0] contains a valuable option as well. Signed-off-by: Miklos Vajna <vmiklos@xxxxxxxxxxxxxx> --- parse-options.c | 5 +++++ parse-options.h | 1 + 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/parse-options.c b/parse-options.c index b98833c..1d01a86 100644 --- a/parse-options.c +++ b/parse-options.c @@ -249,6 +249,11 @@ int parse_options(int argc, const char **argv, const struct option *options, { struct optparse_t args = { argv + 1, argv, argc - 1, 0, NULL }; + if (flags & PARSE_OPT_ARGV0_IS_AN_OPTION) { + args.argv = argv; + args.argc = argc; + } + for (; args.argc; args.argc--, args.argv++) { const char *arg = args.argv[0]; diff --git a/parse-options.h b/parse-options.h index 4ee443d..3238401 100644 --- a/parse-options.h +++ b/parse-options.h @@ -20,6 +20,7 @@ enum parse_opt_type { enum parse_opt_flags { PARSE_OPT_KEEP_DASHDASH = 1, PARSE_OPT_STOP_AT_NON_OPTION = 2, + PARSE_OPT_ARGV0_IS_AN_OPTION = 4, }; enum parse_opt_option_flags { -- 1.5.6 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html