# HG changeset patch # User Guido Berhoerster # Date 1511885784 -3600 # Node ID b5ebed168e591bf76a700ed3e2ec94dcdde6db19 # Parent 9be355e742e590482f041baa27ac1728fb677782 Only invoke pager in the help command for the summary of all commands Display usage information for a single command directly and prefix it with "usage:" like usage error messages. diff -r 9be355e742e5 -r b5ebed168e59 cmd.c --- a/cmd.c Tue Nov 28 16:48:45 2017 +0100 +++ b/cmd.c Tue Nov 28 17:16:24 2017 +0100 @@ -1205,24 +1205,27 @@ return (CMD_USAGE); } - pager = pager_create(STDOUT_FILENO); if (argc == 2) { for (cmd = cmds; cmd->cmd_func != NULL; cmd++) { if ((strcmp(argv[1], cmd->abbrev_cmd) == 0) || (strcmp(argv[1], cmd->full_cmd) == 0)) { - pager_printf(pager, "%s\n", cmd->usage); + if (io_printf("usage: %s\n", cmd->usage) == + IO_SIGNAL) { + retval = CMD_SIGNAL; + } break; } } } else { - printf("Commands:\n"); + pager = pager_create(STDOUT_FILENO); + pager_printf(pager, "Commands:\n"); for (cmd = cmds; cmd->cmd_func != NULL; cmd++) { pager_printf(pager, "%-2s %-16s %s\n", cmd->abbrev_cmd, cmd->full_cmd, cmd->description); } + retval = (pager_show(pager) != IO_SIGNAL) ? CMD_OK : CMD_SIGNAL; + pager_destroy(pager); } - retval = (pager_show(pager) != IO_SIGNAL) ? CMD_OK : CMD_SIGNAL; - pager_destroy(pager); return (retval); }