From df711238fee7423ead0f44e1ca039d1d003175bf Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Wed, 10 Sep 2025 15:34:07 +0200 Subject: [PATCH] system/dd: implement "--help" parameter Previously the usage hints were displayed only in case of errors. Signed-off-by: Lars Kruse --- system/dd/dd_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/system/dd/dd_main.c b/system/dd/dd_main.c index 74cec10eb..f08041836 100644 --- a/system/dd/dd_main.c +++ b/system/dd/dd_main.c @@ -309,6 +309,7 @@ int main(int argc, FAR char **argv) uint32_t sector = 0; int ret = ERROR; int i; + bool show_help = false; /* Initialize the dd structure */ @@ -379,6 +380,10 @@ int main(int argc, FAR char **argv) cur = next + 1; } } + else if (strcmp(argv[i], "--help") == 0) + { + show_help = true; + } else { print_usage(stderr); @@ -386,6 +391,14 @@ int main(int argc, FAR char **argv) } } + /* Help requested? Emit usage hints and exit. */ + + if (show_help) + { + print_usage(stdout); + return 0; + } + /* If verify enabled, infile and outfile are mandatory */ if ((dd.oflags & O_RDONLY) && (infile == NULL || outfile == NULL))