* [PATCH] btrfs-progs: help: recognize '--help' option option regardless of its position in arguments
@ 2024-10-05 6:31 Sidong Yang
0 siblings, 0 replies; only message in thread
From: Sidong Yang @ 2024-10-05 6:31 UTC (permalink / raw)
To: linux-btrfs; +Cc: Sidong Yang
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(-)
diff --git a/btrfs.c b/btrfs.c
index d6f441e8..e34a34ab 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -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);
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-10-05 8:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-05 6:31 [PATCH] btrfs-progs: help: recognize '--help' option option regardless of its position in arguments Sidong Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).