Skip to content

Commit

Permalink
parse-options: make sure argh string does not have SP or _
Browse files Browse the repository at this point in the history
We encourage to spell an argument hint that consists of multiple
words as a single-token separated with dashes.  In order to help
catching violations added by new callers of parse-options, make sure
argh does not contain SP or _ when the code validates the option
definitions.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Mar 24, 2014
1 parent ec160ae commit b6c2a0d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions parse-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ static void parse_options_check(const struct option *opts)
default:
; /* ok. (usually accepts an argument) */
}
if (opts->argh &&
strcspn(opts->argh, " _") != strlen(opts->argh))
err |= optbug(opts, "multi-word argh should use dash to separate words");
}
if (err)
exit(128);
Expand Down

0 comments on commit b6c2a0d

Please sign in to comment.