This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit df711238fee7423ead0f44e1ca039d1d003175bf
Author: Lars Kruse <de...@sumpfralle.de>
AuthorDate: Wed Sep 10 15:34:07 2025 +0200

    system/dd: implement "--help" parameter
    
    Previously the usage hints were displayed only in case of errors.
    
    Signed-off-by: Lars Kruse <de...@sumpfralle.de>
---
 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))

Reply via email to