Skip to content

Commit df71123

Browse files
sumpfrallexiaoxiang781216
authored andcommitted
system/dd: implement "--help" parameter
Previously the usage hints were displayed only in case of errors. Signed-off-by: Lars Kruse <devel@sumpfralle.de>
1 parent db36c8c commit df71123

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

system/dd/dd_main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ int main(int argc, FAR char **argv)
309309
uint32_t sector = 0;
310310
int ret = ERROR;
311311
int i;
312+
bool show_help = false;
312313

313314
/* Initialize the dd structure */
314315

@@ -379,13 +380,25 @@ int main(int argc, FAR char **argv)
379380
cur = next + 1;
380381
}
381382
}
383+
else if (strcmp(argv[i], "--help") == 0)
384+
{
385+
show_help = true;
386+
}
382387
else
383388
{
384389
print_usage(stderr);
385390
goto errout_with_paths;
386391
}
387392
}
388393

394+
/* Help requested? Emit usage hints and exit. */
395+
396+
if (show_help)
397+
{
398+
print_usage(stdout);
399+
return 0;
400+
}
401+
389402
/* If verify enabled, infile and outfile are mandatory */
390403

391404
if ((dd.oflags & O_RDONLY) && (infile == NULL || outfile == NULL))

0 commit comments

Comments
 (0)