summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 82936f2)
raw | patch | inline | side by side (parent: 82936f2)
author | Michele Ballabio <barra_cuda@katamail.com> | |
Sun, 22 Jun 2008 14:39:04 +0000 (16:39 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 23 Jun 2008 01:14:37 +0000 (18:14 -0700) |
When an argument for an option is optional, short options don't need a
space between the option and the argument, and long options need a "=".
Otherwise, arguments are misinterpreted.
Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
space between the option and the argument, and long options need a "=".
Otherwise, arguments are misinterpreted.
Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c | patch | blob | history | |
t/t1502-rev-parse-parseopt.sh | patch | blob | history |
diff --git a/parse-options.c b/parse-options.c
index acf3fe3a1a82cd99e7bd6e0ff9d6d3d7e344a155..f8d52e21fe1f0bced3d4abf081f02000bbd7df62 100644 (file)
--- a/parse-options.c
+++ b/parse-options.c
break;
case OPTION_INTEGER:
if (opts->flags & PARSE_OPT_OPTARG)
- pos += fprintf(stderr, "[<n>]");
+ if (opts->long_name)
+ pos += fprintf(stderr, "[=<n>]");
+ else
+ pos += fprintf(stderr, "[<n>]");
else
pos += fprintf(stderr, " <n>");
break;
case OPTION_STRING:
if (opts->argh) {
if (opts->flags & PARSE_OPT_OPTARG)
- pos += fprintf(stderr, " [<%s>]", opts->argh);
+ if (opts->long_name)
+ pos += fprintf(stderr, "[=<%s>]", opts->argh);
+ else
+ pos += fprintf(stderr, "[<%s>]", opts->argh);
else
pos += fprintf(stderr, " <%s>", opts->argh);
} else {
if (opts->flags & PARSE_OPT_OPTARG)
- pos += fprintf(stderr, " [...]");
+ if (opts->long_name)
+ pos += fprintf(stderr, "[=...]");
+ else
+ pos += fprintf(stderr, "[...]");
else
pos += fprintf(stderr, " ...");
}
index d24a47d1149061565822391542c044a7db193ce5..3508d0a612487be824dfe62eaf2377bc05ae8c17 100755 (executable)
--bar ... some cool option --bar with an argument
An option group Header
- -C [...] option C with an optional argument
+ -C[...] option C with an optional argument
Extras
--extra1 line above used to cause a segfault but no longer does