diff --git a/src/cmd/cmd.c b/src/cmd/cmd.c index 1c5786ee8b..6887454270 100644 --- a/src/cmd/cmd.c +++ b/src/cmd/cmd.c @@ -1018,7 +1018,7 @@ cmd_Parse(int argc, char **argv, struct cmd_syndesc **outsyntax) /* Display full help syntax if we don't have subcommands */ if (noOpcodes) PrintFlagHelp(ts); - code = CMD_USAGE; + code = CMD_HELP; goto out; } @@ -1061,8 +1061,12 @@ cmd_Dispatch(int argc, char **argv) int code; code = cmd_Parse(argc, argv, &ts); - if (code) + if (code) { + if (code == CMD_HELP) { + code = 0; /* displaying help is not an error */ + } return code; + } /* * Before calling the beforeProc and afterProc and all the implications diff --git a/src/cmd/cmd_errors.et b/src/cmd/cmd_errors.et index dbc75e4037..74b1894482 100644 --- a/src/cmd/cmd_errors.et +++ b/src/cmd/cmd_errors.et @@ -20,4 +20,5 @@ error_table CMD ec CMD_TOOBIG, "Token too large" ec CMD_MISSING, "Option not specified on command line" ec CMD_BADFORMAT, "Improper format of configuration file" + ec CMD_HELP, "Help requested" end diff --git a/tests/cmd/command-t.c b/tests/cmd/command-t.c index b4718f37e1..0b0c83f4f6 100644 --- a/tests/cmd/command-t.c +++ b/tests/cmd/command-t.c @@ -330,7 +330,7 @@ main(int argc, char **argv) code = cmd_ParseLine("-help", tv, &tc, 100); is_int(0, code, "cmd_ParseLine succeeds"); code = cmd_Parse(tc, tv, &retopts); - is_int(CMD_USAGE, code, "cmd_Parse returns usage error with help output"); + is_int(CMD_HELP, code, "cmd_Parse returns help indicator with help output"); ok(retopts == NULL, " ... and options is empty"); /* Check splitting with '=' */