[sheepdog] [PATCH] collie: subcommand "cluster recover" refuse option
ChenZhe
cz at de3eb.cn
Fri Mar 15 03:46:54 CET 2013
From: ChenZhe <chenzhe at xinnet.com>
Subcommand "cluster recover" needs the third arg as subcommand, so it refuses the command with any option, because getopt will reorder non-options.
This patch takes optind with 4 while subcmd needs third arg.
Signed-off-by: ChenZhe <chenzhe at xinnet.com>
---
collie/collie.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/collie/collie.c b/collie/collie.c
index 08c78eb..2d05f3d 100644
--- a/collie/collie.c
+++ b/collie/collie.c
@@ -348,6 +348,9 @@ int main(int argc, char **argv)
long_options = build_long_options(sd_opts);
short_options = build_short_options(sd_opts);
+ if(flags & SUBCMD_FLAG_NEED_THIRD_ARG && argc > 3)
+ optind++;
+
while ((ch = getopt_long(argc, argv, short_options, long_options,
&longindex)) >= 0) {
@@ -391,7 +394,7 @@ int main(int argc, char **argv)
}
}
- if (flags & SUBCMD_FLAG_NEED_THIRD_ARG && argc == optind)
+ if (flags & SUBCMD_FLAG_NEED_THIRD_ARG && optind <= 3)
subcommand_usage(argv[1], argv[2], EXIT_USAGE);
return command_fn(argc, argv);
--
1.7.1
More information about the sheepdog
mailing list