scrub/usage-Exit-with-status-code-0-for-help.patch
starlet-dx a36945b514 Fix exit with status code 0 for --help
(cherry picked from commit 3deed882e1717f82aa351800b16f01ad0bec4bb2)
2024-01-30 15:41:47 +08:00

49 lines
1.2 KiB
Diff

From 006fd942abd78d3128d427f1ede9786abe14c65f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Thu, 12 Apr 2018 08:07:29 +0300
Subject: [PATCH] usage: Exit with status code 0 for --help
---
src/scrub.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/scrub.c b/src/scrub.c
index 0a325cb..fceb639 100644
--- a/src/scrub.c
+++ b/src/scrub.c
@@ -110,7 +110,7 @@ static struct option longopts[] = {
char *prog;
static void
-usage(void)
+usage(int rc)
{
fprintf(stderr,
"Usage: %s [OPTIONS] file [file...]\n"
@@ -132,7 +132,7 @@ usage(void)
fprintf(stderr, "Available patterns are:\n");
seq_list ();
- exit(1);
+ exit(rc);
}
int
@@ -225,12 +225,14 @@ main(int argc, char *argv[])
nopt = true;
break;
case 'h': /* --help */
+ usage(0);
+ break;
default:
- usage();
+ usage(1);
}
}
if (argc == optind)
- usage();
+ usage(1);
if (Xopt && argc - optind > 1) {
fprintf(stderr, "%s: -X only takes one directory name\n", prog);
exit(1);