From 52d7de226777a18d35fc2fa30ca022b3495f9f1d Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 15 Dec 2022 08:30:32 -0700 Subject: [PATCH] LU-16329 Revert "LU-8621 utils: cmd help to stdout or short cmd error" This reverts commit 608d763955d7e0a9c438c317e595f14825e9423b. This breaks bash command completion. Fixes: bc69a8d058 ("LU-8621 utils: cmd help to stdout, short cmd error") Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I004ea5af499593b0f36ba17ff5f517548f0ea0f9 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49416 Tested-by: jenkins Tested-by: Maloo --- libcfs/libcfs/util/parser.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/libcfs/libcfs/util/parser.c b/libcfs/libcfs/util/parser.c index d707330..c5c8947 100644 --- a/libcfs/libcfs/util/parser.c +++ b/libcfs/libcfs/util/parser.c @@ -117,16 +117,14 @@ int Parser_execarg(int argc, char **argv, command_t cmds[]) if (cmd && cmd->pc_func) { int rc = cmd->pc_func(argc, argv); - if (rc == CMD_HELP) { - fprintf(stdout, "%s\n", cmd->pc_help); - fflush(stdout); - } + if (rc == CMD_HELP) + fprintf(stderr, "%s\n", cmd->pc_help); return rc; } - fprintf(stderr, - "%s: '%s' is not a valid command. See '%s --list-commands'.\n", - program_invocation_short_name, argv[0], - program_invocation_short_name); + printf("Try interactive use without arguments or use one of:\n"); + for (cmd = cmds; cmd->pc_name; cmd++) + printf("\"%s\"\n", cmd->pc_name); + printf("as argument.\n"); return -1; } @@ -298,10 +296,8 @@ int execute_line(char *line) i = line2args(line, argv, MAXARGS); rc = cmd->pc_func(i, argv); - if (rc == CMD_HELP) { - fprintf(stdout, "%s\n", cmd->pc_help); - fflush(stdout); - } + if (rc == CMD_HELP) + fprintf(stderr, "%s\n", cmd->pc_help); break; } @@ -468,8 +464,8 @@ void Parser_qhelp(int argc, char *argv[]) program_invocation_short_name); printf("Without any parameters, interactive mode is invoked\n"); - printf("Try '%s help ', or '%s --list-commands' for a list of commands.\n", - program_invocation_short_name, program_invocation_short_name); + printf("Try '%s help ' or '%s --list-commands' for more information\n", + program_invocation_short_name, program_invocation_short_name); } int Parser_help(int argc, char **argv) -- 1.8.3.1