[sheepdog] [PATCH] collie: fix the output of 'collie --help'

MORITA Kazutaka morita.kazutaka at gmail.com
Thu May 30 18:29:13 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

Without this patch, the output of 'collie --help' is as follows:

  $ collie --help
  Invalid command '--help'
  Try 'collie --help' for more information.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 collie/collie.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/collie/collie.c b/collie/collie.c
index 3c975ff..7975b47 100644
--- a/collie/collie.c
+++ b/collie/collie.c
@@ -185,8 +185,12 @@ static unsigned long setup_commands(const struct command *commands,
 	}
 
 	if (!found) {
-		fprintf(stderr, "Invalid command '%s'\n", cmd);
-		usage(commands, EXIT_USAGE);
+		if (cmd && strcmp(cmd, "help") && strcmp(cmd, "--help") &&
+		    strcmp(cmd, "-h")) {
+			fprintf(stderr, "Invalid command '%s'\n", cmd);
+			usage(commands, EXIT_USAGE);
+		}
+		usage(commands, 0);
 	}
 
 	for (s = commands[i].sub; subcmd && s->name; s++) {
@@ -203,7 +207,7 @@ static unsigned long setup_commands(const struct command *commands,
 
 	if (!command_fn) {
 		if (subcmd && strcmp(subcmd, "help") &&
-		    strcmp(subcmd, "--help"))
+		    strcmp(subcmd, "--help") && strcmp(subcmd, "-h"))
 			fprintf(stderr, "Invalid command '%s %s'\n", cmd, subcmd);
 		fprintf(stderr, "Available %s commands:\n", cmd);
 		for (s = commands[i].sub; s->name; s++)
-- 
1.7.9.5




More information about the sheepdog mailing list