From 8aaf5be82afa644b261db02721dbb0edb02f463a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 29 Aug 2021 10:32:15 +0300 Subject: [PATCH] Exit status fixes. Previously help and all usage errors resulted in exit status 255, which is unconventional. Treat help as non-error, and error with status 2 for usage errors to match more common command behavior. The exit status of -? changes to that of an usage error, even though it is listed as one of the help invoking options, due to getopt_long behavior. --- main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index f70c53a..4519a63 100644 --- a/main.c +++ b/main.c @@ -409,9 +409,9 @@ int main(int argc, char *argv[]) control->flags |= FLAG_FORCE_REPLACE; break; case 'h': - case '?': usage(compat); - return -1; + exit(0); + break; case 'H': control->flags |= FLAG_HASH; break; @@ -544,6 +544,9 @@ int main(int argc, char *argv[]) case '9': control->compression_level = c - '0'; break; + default: + usage(compat); + return 2; } }