From 38916c5b4740f6db09dc140a84bb470dfb582366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 3 Mar 2012 12:00:29 +0100 Subject: parse-options: typo check for unknown switches The user specifies a long option but forgets to type the second leading dash, we currently detect and report that fact if its first letter is a valid short option. This is done for safety, to avoid ambiguity between short options (and their arguments) and a long option with a missing dash. This diagnostic message is also helpful for long options whose first letter is not a valid short option, however. Print it in that case, too, as a courtesy. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- parse-options.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'parse-options.c') diff --git a/parse-options.c b/parse-options.c index 190899611e..850cfa78c9 100644 --- a/parse-options.c +++ b/parse-options.c @@ -393,6 +393,8 @@ int parse_options_step(struct parse_opt_ctx_t *ctx, case -1: return parse_options_usage(ctx, usagestr, options, 1); case -2: + if (ctx->opt) + check_typos(arg + 1, options); goto unknown; } if (ctx->opt) -- cgit v1.2.3