Whamcloud - gitweb
LU-16329 Revert "LU-8621 utils: cmd help to stdout or short cmd error"
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 15 Dec 2022 15:30:32 +0000 (08:30 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 17 Dec 2022 02:22:52 +0000 (02:22 +0000)
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 <adilger@whamcloud.com>
Change-Id: I004ea5af499593b0f36ba17ff5f517548f0ea0f9
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49416
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
libcfs/libcfs/util/parser.c

index d707330..c5c8947 100644 (file)
@@ -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 <COMMAND>', or '%s --list-commands' for a list of commands.\n",
-               program_invocation_short_name, program_invocation_short_name);
+       printf("Try '%s help <COMMAND>' or '%s --list-commands' for more information\n",
+              program_invocation_short_name, program_invocation_short_name);
 }
 
 int Parser_help(int argc, char **argv)