@@ -140,19 +140,23 @@ static void check_command_flags(const struct cmd_struct *cmd)
static void handle_help_options_next_level(const struct cmd_struct *cmd,
int argc, char **argv)
{
+ int i;
if (argc < 2)
return;
- if (!strcmp(argv[1], "--help")) {
- if (cmd->next) {
- argc--;
- argv++;
- help_command_group(cmd->next, argc, argv);
- } else {
- usage_command(cmd, true, false);
+ for (i=0; i<argc; ++i) {
+ if (!strcmp(argv[i], "--help")) {
+ if (cmd->next) {
+ argc -= i+1;
+ argv += i+1;
+ help_command_group(cmd->next, argc, argv);
+ } else {
+ usage_command(cmd, true, false);
+ }
+
+ exit(0);
}
- exit(0);
}
}
Currently, the handle_help_options_next_level() function only checks for the '--help' option at first. This means that if user provides the option at no first, the help message is not displayed. This patch modifies the function to check all arguments for the command. Issue: #889 Signed-off-by: Sidong Yang <realwakka@gmail.com> --- btrfs.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)