Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit b141a47

Browse files
kusmagitster
authored andcommitted
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 <[email protected]> Improved-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 901fd18 commit b141a47

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

parse-options.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,11 @@ int parse_options(int argc, const char **argv, const char *prefix,
470470
default: /* PARSE_OPT_UNKNOWN */
471471
if (ctx.argv[0][1] == '-') {
472472
error("unknown option `%s'", ctx.argv[0] + 2);
473-
} else {
473+
} else if (isascii(*ctx.opt)) {
474474
error("unknown switch `%c'", *ctx.opt);
475+
} else {
476+
error("unknown non-ascii option in string: `%s'",
477+
ctx.argv[0]);
475478
}
476479
usage_with_options(usagestr, options);
477480
}

0 commit comments

Comments
 (0)