diff options
author | Marco d'Itri <md@linux.it> | 2013-04-10 03:35:05 +0200 |
---|---|---|
committer | Marco d'Itri <md@linux.it> | 2013-04-10 17:25:05 +0200 |
commit | 865f6025eb4c7cbf11b73ec6de97f924e70cae8b (patch) | |
tree | 0f5e1561b32f135a008e03fd71e2e70f2b1cd8fb /mkpasswd.c | |
parent | 361164fea52c942279b47fd3406f82dfb0173b1b (diff) | |
download | whois-865f6025eb4c7cbf11b73ec6de97f924e70cae8b.tar.gz |
Handle --help as success for mkpasswd too
Diffstat (limited to 'mkpasswd.c')
-rw-r--r-- | mkpasswd.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -114,7 +114,7 @@ static const struct crypt_method methods[] = { void generate_salt(char *const buf, const unsigned int len); void *get_random_bytes(const int len); -void display_help(void); +void display_help(int error); void display_version(void); void display_methods(void); @@ -196,8 +196,7 @@ int main(int argc, char *argv[]) display_version(); exit(0); case 'h': - display_help(); - exit(0); + display_help(EXIT_SUCCESS); default: fprintf(stderr, _("Try '%s --help' for more information.\n"), argv[0]); @@ -214,8 +213,7 @@ int main(int argc, char *argv[]) password = argv[0]; } else if (argc == 0) { } else { - display_help(); - exit(1); + display_help(EXIT_FAILURE); } /* default: DES password */ @@ -415,9 +413,10 @@ void generate_salt(char *const buf, const unsigned int len) #endif /* RANDOM_DEVICE */ -void display_help(void) +void display_help(int error) { - fprintf(stderr, _("Usage: mkpasswd [OPTIONS]... [PASSWORD [SALT]]\n" + fprintf((EXIT_SUCCESS == error) ? stdout : stderr, + _("Usage: mkpasswd [OPTIONS]... [PASSWORD [SALT]]\n" "Crypts the PASSWORD using crypt(3).\n\n")); fprintf(stderr, _( " -m, --method=TYPE select method TYPE\n" @@ -435,6 +434,7 @@ void display_help(void) "If TYPE is 'help', available methods are printed.\n" "\n" "Report bugs to %s.\n"), "<md+whois@linux.it>"); + exit(error); } void display_version(void) |