Skip to content

Commit

Permalink
parseopt: add flag to stop on first non option
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Mar 1, 2008
1 parent 363d59d commit a0ec9d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions parse-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ int parse_options(int argc, const char **argv, const struct option *options,
const char *arg = args.argv[0];

if (*arg != '-' || !arg[1]) {
if (flags & PARSE_OPT_STOP_AT_NON_OPTION)
break;
argv[j++] = args.argv[0];
continue;
}
Expand Down
1 change: 1 addition & 0 deletions parse-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum parse_opt_type {

enum parse_opt_flags {
PARSE_OPT_KEEP_DASHDASH = 1,
PARSE_OPT_STOP_AT_NON_OPTION = 2,
};

enum parse_opt_option_flags {
Expand Down

0 comments on commit a0ec9d2

Please sign in to comment.