system/dd: implement "--help" parameter

Previously the usage hints were displayed only in case of errors.

Signed-off-by: Lars Kruse <devel@sumpfralle.de>
This commit is contained in:
Lars Kruse 2025-09-10 15:34:07 +02:00 committed by Xiang Xiao
parent db36c8c617
commit df711238fe

View file

@ -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))