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

Liu Yuan namei.unix at gmail.com
Fri May 31 05:23:07 CEST 2013


On 05/31/2013 12:29 AM, MORITA Kazutaka wrote:
> 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++)
> 

Applied, thanks.

Yuan



More information about the sheepdog mailing list