summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 934f788)
raw | patch | inline | side by side (parent: 934f788)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sun, 8 Mar 2009 18:12:47 +0000 (19:12 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 8 Mar 2009 20:36:09 +0000 (13:36 -0700) |
Add a parseopt flag, PARSE_OPT_KEEP_UNKNOWN, that can be used to keep
unknown options in argv, similar to the existing KEEP flags.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unknown options in argv, similar to the existing KEEP flags.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c | patch | blob | history | |
parse-options.h | patch | blob | history |
diff --git a/parse-options.c b/parse-options.c
index 4c5d09dd25aede8ea7e14886f5c17ed847a8f0d9..39808ae45850c7dc96f6288b969ba34be1556c39 100644 (file)
--- a/parse-options.c
+++ b/parse-options.c
case -1:
return parse_options_usage(usagestr, options);
case -2:
- return PARSE_OPT_UNKNOWN;
+ goto unknown;
}
if (ctx->opt)
check_typos(arg + 1, options);
*/
ctx->argv[0] = xstrdup(ctx->opt - 1);
*(char *)ctx->argv[0] = '-';
- return PARSE_OPT_UNKNOWN;
+ goto unknown;
}
}
continue;
case -1:
return parse_options_usage(usagestr, options);
case -2:
- return PARSE_OPT_UNKNOWN;
+ goto unknown;
}
+ continue;
+unknown:
+ if (!(ctx->flags & PARSE_OPT_KEEP_UNKNOWN))
+ return PARSE_OPT_UNKNOWN;
+ ctx->out[ctx->cpidx++] = ctx->argv[0];
+ ctx->opt = NULL;
}
return PARSE_OPT_DONE;
}
diff --git a/parse-options.h b/parse-options.h
index 912290549bcbb03b7e82750a40297fb1a70b8206..b7d08b13d1493c0091f2431962a8bcb86ed035a8 100644 (file)
--- a/parse-options.h
+++ b/parse-options.h
PARSE_OPT_KEEP_DASHDASH = 1,
PARSE_OPT_STOP_AT_NON_OPTION = 2,
PARSE_OPT_KEEP_ARGV0 = 4,
+ PARSE_OPT_KEEP_UNKNOWN = 8,
};
enum parse_opt_option_flags {