Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

parse-options: report uncorrupted multi-byte options

Because our command-line parser considers only one byte at the time
for short-options, we incorrectly report only the first byte when
multi-byte input was provided. This makes user-errors slightly
awkward to diagnose for instance under UTF-8 locale and non-English
keyboard layouts.

Report the whole argument-string when a non-ASCII short-option is
detected.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Improved-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information...
commit b141a47801d6fb2d68ec48adfe7597ec3ce49c0d 1 parent 901fd18
Erik Faye-Lund authored February 12, 2013 gitster committed February 11, 2013

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. 5  parse-options.c
5  parse-options.c
@@ -470,8 +470,11 @@ int parse_options(int argc, const char **argv, const char *prefix,
470 470
 	default: /* PARSE_OPT_UNKNOWN */
471 471
 		if (ctx.argv[0][1] == '-') {
472 472
 			error("unknown option `%s'", ctx.argv[0] + 2);
473  
-		} else {
  473
+		} else if (isascii(*ctx.opt)) {
474 474
 			error("unknown switch `%c'", *ctx.opt);
  475
+		} else {
  476
+			error("unknown non-ascii option in string: `%s'",
  477
+			      ctx.argv[0]);
475 478
 		}
476 479
 		usage_with_options(usagestr, options);
477 480
 	}

0 notes on commit b141a47

Please sign in to comment.
Something went wrong with that request. Please try again.