From: Jens Axboe Date: Tue, 9 Jan 2007 20:22:02 +0000 (+0100) Subject: [PATCH] Complain if bad option given to 'cmdhelp' X-Git-Tag: fio-1.12~180 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=29fc6afe1bfcb97dd7f33d8e58b99b2d93237d47 [PATCH] Complain if bad option given to 'cmdhelp' Signed-off-by: Jens Axboe --- diff --git a/init.c b/init.c index 4ac2783d..aca607dc 100644 --- a/init.c +++ b/init.c @@ -1205,8 +1205,8 @@ static int parse_cmd_line(int argc, char *argv[]) usage(); exit(0); case 'c': - show_cmd_help(options, optarg); - exit(0); + ret = show_cmd_help(options, optarg); + exit(ret); case 'v': printf("%s\n", fio_version_string); exit(0); diff --git a/parse.c b/parse.c index 7ff474b1..ad096918 100644 --- a/parse.c +++ b/parse.c @@ -376,11 +376,13 @@ int show_cmd_help(struct fio_option *options, const char *name) "integer value (opt=100)", "no argument (opt)", }; + int found = 0; while (o->name) { int match = !strcmp(name, o->name); if (show_all || match) { + found = 1; printf("%s: %s\n", o->name, o->help); if (match) printf("type: %s\n", typehelp[o->type]); @@ -389,6 +391,9 @@ int show_cmd_help(struct fio_option *options, const char *name) o++; } + if (found) + return 0; - return 0; + printf("No such command: %s\n", name); + return 1; }