[Pkg-shadow-devel] [PATCH] send --help output to stdout

Mike Frysinger vapier at gentoo.org
Thu Aug 27 11:26:33 UTC 2009


If someone uses the -h/--help options, the usage should not go to stderr
nor should the utility exit with non-zero status.  All of the shadow utils
do just this unfortunately, so convert them over to sanity.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 src/chage.c     |   27 +++++++++---------
 src/chgpasswd.c |   20 +++++++-------
 src/chpasswd.c  |   32 +++++++++++-----------
 src/chsh.c      |   13 ++++-----
 src/faillog.c   |   31 +++++++++++----------
 src/gpasswd.c   |   19 +++++++-----
 src/groupadd.c  |   32 +++++++++++-----------
 src/groupmems.c |   16 ++++++-----
 src/groupmod.c  |   28 ++++++++++---------
 src/lastlog.c   |   12 ++++----
 src/newusers.c  |   28 +++++++++---------
 src/passwd.c    |    6 +++-
 src/su.c        |   10 +++---
 src/useradd.c   |   82 +++++++++++++++++++++++++++---------------------------
 src/userdel.c   |   13 +++++----
 src/usermod.c   |   25 +++++++++--------
 src/vipw.c      |   11 +++----
 17 files changed, 207 insertions(+), 198 deletions(-)

diff --git a/src/chage.c b/src/chage.c
index 4a28890..308c5c6 100644
--- a/src/chage.c
+++ b/src/chage.c
@@ -91,7 +91,6 @@ static long expdate;
 
 /* local function prototypes */
 static bool isnum (const char *s);
-static void usage (void);
 static void date_to_str (char *buf, size_t maxsize, time_t date);
 static int new_fields (void);
 static void print_date (time_t date);
@@ -152,7 +151,7 @@ static bool isnum (const char *s)
 /*
  * usage - print command line syntax and exit
  */
-static void usage (void)
+static void usage (int status)
 {
 	fputs (_("Usage: chage [options] [LOGIN]\n"
 	         "\n"
@@ -168,8 +167,8 @@ static void usage (void)
 	         "  -M, --maxdays MAX_DAYS        set maximim number of days before password\n"
 	         "                                change to MAX_DAYS\n"
 	         "  -W, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS\n"
-	         "\n"), stderr);
-	exit (E_USAGE);
+	         "\n"), status ? stderr : stdout);
+	exit (status);
 }
 
 static void date_to_str (char *buf, size_t maxsize, time_t date)
@@ -413,7 +412,7 @@ static void process_flags (int argc, char **argv)
 				fprintf (stderr,
 				         _("%s: invalid date '%s'\n"),
 				         Prog, optarg);
-				usage ();
+				usage (E_USAGE);
 			}
 			break;
 		case 'E':
@@ -425,11 +424,11 @@ static void process_flags (int argc, char **argv)
 				fprintf (stderr,
 				         _("%s: invalid date '%s'\n"),
 				         Prog, optarg);
-				usage ();
+				usage (E_USAGE);
 			}
 			break;
 		case 'h':
-			usage ();
+			usage (E_SUCCESS);
 			break;
 		case 'I':
 			Iflg = true;
@@ -438,7 +437,7 @@ static void process_flags (int argc, char **argv)
 				fprintf (stderr,
 				         _("%s: invalid numeric argument '%s'\n"),
 				         Prog, optarg);
-				usage ();
+				usage (E_USAGE);
 			}
 			break;
 		case 'l':
@@ -451,7 +450,7 @@ static void process_flags (int argc, char **argv)
 				fprintf (stderr,
 				         _("%s: invalid numeric argument '%s'\n"),
 				         Prog, optarg);
-				usage ();
+				usage (E_USAGE);
 			}
 			break;
 		case 'M':
@@ -461,7 +460,7 @@ static void process_flags (int argc, char **argv)
 				fprintf (stderr,
 				         _("%s: invalid numeric argument '%s'\n"),
 				         Prog, optarg);
-				usage ();
+				usage (E_USAGE);
 			}
 			break;
 		case 'W':
@@ -471,11 +470,11 @@ static void process_flags (int argc, char **argv)
 				fprintf (stderr,
 				         _("%s: invalid numeric argument '%s'\n"),
 				         Prog, optarg);
-				usage ();
+				usage (E_USAGE);
 			}
 			break;
 		default:
-			usage ();
+			usage (E_USAGE);
 		}
 	}
 
@@ -495,14 +494,14 @@ static void check_flags (int argc, int opt_index)
 	 */
 
 	if (argc != opt_index + 1) {
-		usage ();
+		usage (E_USAGE);
 	}
 
 	if (lflg && (mflg || Mflg || dflg || Wflg || Iflg || Eflg)) {
 		fprintf (stderr,
 		         _("%s: do not include \"l\" with other flags\n"),
 		         Prog);
-		usage ();
+		usage (E_USAGE);
 	}
 }
 
diff --git a/src/chgpasswd.c b/src/chgpasswd.c
index d49d141..44f483a 100644
--- a/src/chgpasswd.c
+++ b/src/chgpasswd.c
@@ -78,7 +78,6 @@ static bool gr_locked = false;
 
 /* local function prototypes */
 static void fail_exit (int code);
-static void usage (void);
 static void process_flags (int argc, char **argv);
 static void check_flags (void);
 static void check_perms (void);
@@ -114,9 +113,10 @@ static void fail_exit (int code)
 /*
  * usage - display usage message and exit
  */
-static void usage (void)
+static void usage (int status)
 {
-	fprintf (stderr, _("Usage: %s [options]\n"
+	fprintf (status ? stderr : stdout,
+	                 _("Usage: %s [options]\n"
 	                   "\n"
 	                   "Options:\n"
 	                   "  -c, --crypt-method            the crypt method (one of %s)\n"
@@ -135,7 +135,7 @@ static void usage (void)
 	                   "                                crypt algorithms\n")
 #endif
 	                 );
-	exit (E_USAGE);
+	exit (status);
 }
 
 /*
@@ -174,7 +174,7 @@ static void process_flags (int argc, char **argv)
 			eflg = true;
 			break;
 		case 'h':
-			usage ();
+			usage (E_SUCCESS);
 			break;
 		case 'm':
 			md5flg = true;
@@ -186,12 +186,12 @@ static void process_flags (int argc, char **argv)
 				fprintf (stderr,
 				         _("%s: invalid numeric argument '%s'\n"),
 				         Prog, optarg);
-				usage ();
+				usage (E_USAGE);
 			}
 			break;
 #endif
 		default:
-			usage ();
+			usage (E_USAGE);
 			break;
 		}
 	}
@@ -212,7 +212,7 @@ static void check_flags (void)
 		fprintf (stderr,
 		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-s", "-c");
-		usage ();
+		usage (E_USAGE);
 	}
 #endif
 
@@ -221,7 +221,7 @@ static void check_flags (void)
 		fprintf (stderr,
 		         _("%s: the -c, -e, and -m flags are exclusive\n"),
 		         Prog);
-		usage ();
+		usage (E_USAGE);
 	}
 
 	if (cflg) {
@@ -236,7 +236,7 @@ static void check_flags (void)
 			fprintf (stderr,
 			         _("%s: unsupported crypt method: %s\n"),
 			         Prog, crypt_method);
-			usage ();
+			usage (E_USAGE);
 		}
 	}
 }
diff --git a/src/chpasswd.c b/src/chpasswd.c
index e4334ae..903c57f 100644
--- a/src/chpasswd.c
+++ b/src/chpasswd.c
@@ -74,7 +74,6 @@ static bool spw_locked = false;
 
 /* local function prototypes */
 static void fail_exit (int code);
-static void usage (void);
 static void process_flags (int argc, char **argv);
 static void check_flags (void);
 static void check_perms (void);
@@ -112,15 +111,16 @@ static void fail_exit (int code)
 /*
  * usage - display usage message and exit
  */
-static void usage (void)
+static void usage (int status)
 {
-	(void) fprintf (stderr,
+	FILE *usageout = status ? stderr : stdout;
+	(void) fprintf (usageout,
 	                _("Usage: %s [options]\n"
 	                  "\n"
 	                  "Options:\n"),
 	                Prog);
 #ifndef USE_PAM
-	(void) fprintf (stderr,
+	(void) fprintf (usageout,
 	                _("  -c, --crypt-method            the crypt method (one of %s)\n"),
 #ifndef USE_SHA_CRYPT
 	                "NONE DES MD5"
@@ -128,22 +128,22 @@ static void usage (void)
 	                "NONE DES MD5 SHA256 SHA512"
 #endif				/* USE_SHA_CRYPT */
 	               );
-	(void) fputs (_("  -e, --encrypted               supplied passwords are encrypted\n"), stderr);
+	(void) fputs (_("  -e, --encrypted               supplied passwords are encrypted\n"), usageout);
 #endif				/* !USE_PAM */
-	(void) fputs (_("  -h, --help                    display this help message and exit\n"), stderr);
+	(void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
 #ifndef USE_PAM
 	(void) fputs (_("  -m, --md5                     encrypt the clear text password using\n"
 	                "                                the MD5 algorithm\n"),
-	              stderr);
+	              usageout);
 #ifdef USE_SHA_CRYPT
 	(void) fputs (_("  -s, --sha-rounds              number of SHA rounds for the SHA*\n"
 	                "                                crypt algorithms\n"),
-	              stderr);
+	              usageout);
 #endif				/* USE_SHA_CRYPT */
 #endif				/* !USE_PAM */
-	(void) fputs ("\n", stderr);
+	(void) fputs ("\n", usageout);
 
-	exit (E_USAGE);
+	exit (status);
 }
 
 /*
@@ -181,7 +181,7 @@ static void process_flags (int argc, char **argv)
 	                         long_options, &option_index)) != -1) {
 		switch (c) {
 		case 'h':
-			usage ();
+			usage (E_SUCCESS);
 			break;
 #ifndef USE_PAM
 		case 'c':
@@ -201,13 +201,13 @@ static void process_flags (int argc, char **argv)
 				fprintf (stderr,
 				         _("%s: invalid numeric argument '%s'\n"),
 				         Prog, optarg);
-				usage ();
+				usage (E_USAGE);
 			}
 			break;
 #endif				/* USE_SHA_CRYPT */
 #endif				/* !USE_PAM */
 		default:
-			usage ();
+			usage (E_USAGE);
 			break;
 		}
 	}
@@ -229,7 +229,7 @@ static void check_flags (void)
 		fprintf (stderr,
 		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-s", "-c");
-		usage ();
+		usage (E_USAGE);
 	}
 #endif
 
@@ -238,7 +238,7 @@ static void check_flags (void)
 		fprintf (stderr,
 		         _("%s: the -c, -e, and -m flags are exclusive\n"),
 		         Prog);
-		usage ();
+		usage (E_USAGE);
 	}
 
 	if (cflg) {
@@ -253,7 +253,7 @@ static void check_flags (void)
 			fprintf (stderr,
 			         _("%s: unsupported crypt method: %s\n"),
 			         Prog, crypt_method);
-			usage ();
+			usage (E_USAGE);
 		}
 	}
 #endif				/* USE_PAM */
diff --git a/src/chsh.c b/src/chsh.c
index b50b4f7..512c63e 100644
--- a/src/chsh.c
+++ b/src/chsh.c
@@ -72,7 +72,6 @@ static bool pw_locked = false;
 
 /* local function prototypes */
 static void fail_exit (int code);
-static void usage (void);
 static void new_fields (void);
 static bool shell_is_listed (const char *);
 static bool is_restricted_shell (const char *);
@@ -101,15 +100,15 @@ static void fail_exit (int code)
 /*
  * usage - print command line syntax and exit
  */
-static void usage (void)
+static void usage (int status)
 {
 	fputs (_("Usage: chsh [options] [LOGIN]\n"
 	         "\n"
 	         "Options:\n"
 	         "  -h, --help                    display this help message and exit\n"
 	         "  -s, --shell SHELL             new login shell for the user account\n"
-	         "\n"), stderr);
-	exit (E_USAGE);
+	         "\n"), status ? stderr : stdout);
+	exit (status);
 }
 
 /*
@@ -217,14 +216,14 @@ static void process_flags (int argc, char **argv)
 		             &option_index)) != -1) {
 		switch (c) {
 		case 'h':
-			usage ();
+			usage (E_SUCCESS);
 			break;
 		case 's':
 			sflg = true;
 			STRFCPY (loginsh, optarg);
 			break;
 		default:
-			usage ();
+			usage (E_USAGE);
 		}
 	}
 
@@ -233,7 +232,7 @@ static void process_flags (int argc, char **argv)
 	 * be the user's name.
 	 */
 	if (argc > (optind + 1)) {
-		usage ();
+		usage (E_USAGE);
 	}
 }
 
diff --git a/src/faillog.c b/src/faillog.c
index 15e0751..ee0be3f 100644
--- a/src/faillog.c
+++ b/src/faillog.c
@@ -69,24 +69,25 @@ static struct stat statbuf;	/* fstat buffer for file size */
 
 #define	NOW	(time((time_t *) 0))
 
-static void usage (void)
+static void usage (int status)
 {
-	(void) fprintf (stderr,
+	FILE *usageout = status ? stderr : stdout;
+	(void) fprintf (usageout,
 	                _("Usage: %s [options]\n"
 	                  "\n"
 	                  "Options:\n"),
 	                "faillog");
-	(void) fputs (_("  -a, --all                     display faillog records for all users\n"), stderr);
-	(void) fputs (_("  -h, --help                    display this help message and exit\n"), stderr);
-	(void) fputs (_("  -l, --lock-time SEC           after failed login lock account for SEC seconds\n"), stderr);
-	(void) fputs (_("  -m, --maximum MAX             set maximum failed login counters to MAX\n"), stderr);
-	(void) fputs (_("  -r, --reset                   reset the counters of login failures\n"), stderr);
-	(void) fputs (_("  -t, --time DAYS               display faillog records more recent than DAYS\n"), stderr);
+	(void) fputs (_("  -a, --all                     display faillog records for all users\n"), usageout);
+	(void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
+	(void) fputs (_("  -l, --lock-time SEC           after failed login lock account for SEC seconds\n"), usageout);
+	(void) fputs (_("  -m, --maximum MAX             set maximum failed login counters to MAX\n"), usageout);
+	(void) fputs (_("  -r, --reset                   reset the counters of login failures\n"), usageout);
+	(void) fputs (_("  -t, --time DAYS               display faillog records more recent than DAYS\n"), usageout);
 	(void) fputs (_("  -u, --user LOGIN/RANGE        display faillog record or maintains failure\n"
 	                "                                counters and limits (if used with -r, -m,\n"
-	                "                                or -l) only for the specified LOGIN(s)\n"), stderr);
-	(void) fputs ("\n", stderr);
-	exit (E_USAGE);
+	                "                                or -l) only for the specified LOGIN(s)\n"), usageout);
+	(void) fputs ("\n", usageout);
+	exit (status);
 }
 
 static void print_one (/*@null@*/const struct passwd *pw, bool force)
@@ -495,7 +496,7 @@ int main (int argc, char **argv)
 				aflg = true;
 				break;
 			case 'h':
-				usage ();
+				usage (E_SUCCESS);
 				break;
 			case 'l':
 				if (getlong (optarg, &fail_locktime) == 0) {
@@ -561,16 +562,16 @@ int main (int argc, char **argv)
 				break;
 			}
 			default:
-				usage ();
+				usage (E_USAGE);
 			}
 		}
 	}
 
 	if (aflg && uflg) {
-		usage ();
+		usage (E_USAGE);
 	}
 	if (tflg && (lflg || mflg || rflg)) {
-		usage ();
+		usage (E_USAGE);
 	}
 
 	/* Open the faillog database */
diff --git a/src/gpasswd.c b/src/gpasswd.c
index 5def9a8..2733b22 100644
--- a/src/gpasswd.c
+++ b/src/gpasswd.c
@@ -94,7 +94,6 @@ static uid_t bywho;
 #endif
 
 /* local function prototypes */
-static void usage (void);
 static RETSIGTYPE catch_signals (int killed);
 static bool is_valid_user_list (const char *users);
 static void process_flags (int argc, char **argv);
@@ -128,14 +127,15 @@ static void log_gpasswd_success_gshadow (unused void *arg);
 /*
  * usage - display usage message
  */
-static void usage (void)
+static void usage (int status)
 {
-	fprintf (stderr,
+	fprintf (status ? stderr : stdout,
 	         _("Usage: %s [option] GROUP\n"
 	           "\n"
 	           "Options:\n"
 	           "  -a, --add USER                add USER to GROUP\n"
 	           "  -d, --delete USER             remove USER from GROUP\n"
+	           "  -h, --help                    display this help message and exit\n"
 	           "  -r, --remove-password         remove the GROUP's password\n"
 	           "  -R, --restrict                restrict access to GROUP to its members\n"
 	           "  -M, --members USER,...        set the list of members of GROUP\n"
@@ -150,7 +150,7 @@ static void usage (void)
 	         _("The options cannot be combined.\n")
 #endif
 	        );
-	exit (E_USAGE);
+	exit (status);
 }
 
 /*
@@ -235,6 +235,7 @@ static void process_flags (int argc, char **argv)
 	static struct option long_options[] = {
 		{"add", required_argument, NULL, 'a'},
 		{"delete", required_argument, NULL, 'd'},
+		{"help", no_argument, NULL, 'h'},
 		{"remove-password", no_argument, NULL, 'r'},
 		{"restrict", no_argument, NULL, 'R'},
 		{"administrators", required_argument, NULL, 'A'},
@@ -242,7 +243,7 @@ static void process_flags (int argc, char **argv)
 		{NULL, 0, NULL, '\0'}
 		};
 
-	while ((flag = getopt_long (argc, argv, "a:A:d:gM:rR", long_options, &option_index)) != -1) {
+	while ((flag = getopt_long (argc, argv, "a:A:d:ghM:rR", long_options, &option_index)) != -1) {
 		switch (flag) {
 		case 'a':	/* add a user */
 			aflg = true;
@@ -276,6 +277,8 @@ static void process_flags (int argc, char **argv)
 			break;
 		case 'g':	/* no-op from normal password */
 			break;
+		case 'h':
+			usage (E_SUCCESS);
 		case 'M':	/* set the list of members */
 			members = optarg;
 			if (!is_valid_user_list (members)) {
@@ -290,7 +293,7 @@ static void process_flags (int argc, char **argv)
 			Rflg = true;
 			break;
 		default:
-			usage ();
+			usage (E_USAGE);
 		}
 	}
 
@@ -325,14 +328,14 @@ static void check_flags (int argc, int opt_index)
 		exclusive++;
 	}
 	if (exclusive > 1) {
-		usage ();
+		usage (E_USAGE);
 	}
 
 	/*
 	 * Make sure one (and only one) group was provided
 	 */
 	if ((argc != (opt_index+1)) || (NULL == group)) {
-		usage ();
+		usage (E_USAGE);
 	}
 }
 
diff --git a/src/groupadd.c b/src/groupadd.c
index 8bb48ef..09eadbd 100644
--- a/src/groupadd.c
+++ b/src/groupadd.c
@@ -88,7 +88,6 @@ static bool is_shadow_grp;
 #endif
 
 /* local function prototypes */
-static void usage (void);
 static void new_grent (struct group *grent);
 
 #ifdef SHADOWGRP
@@ -105,24 +104,25 @@ static void check_perms (void);
 /*
  * usage - display usage message and exit
  */
-static void usage (void)
+static void usage (int status)
 {
-	(void) fprintf (stderr,
+	FILE *usageout = status ? stderr : stdout;
+	(void) fprintf (usageout,
 	                _("Usage: %s [options] GROUP\n"
 	                  "\n"
 	                  "Options:\n"),
 	                Prog);
 	(void) fputs (_("  -f, --force                   exit successfully if the group already exists,\n"
-	                "                                and cancel -g if the GID is already used\n"), stderr);
-	(void) fputs (_("  -g, --gid GID                 use GID for the new group\n"), stderr);
-	(void) fputs (_("  -h, --help                    display this help message and exit\n"), stderr);
-	(void) fputs (_("  -K, --key KEY=VALUE           override /etc/login.defs defaults\n"), stderr);
+	                "                                and cancel -g if the GID is already used\n"), usageout);
+	(void) fputs (_("  -g, --gid GID                 use GID for the new group\n"), usageout);
+	(void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
+	(void) fputs (_("  -K, --key KEY=VALUE           override /etc/login.defs defaults\n"), usageout);
 	(void) fputs (_("  -o, --non-unique              allow to create groups with duplicate\n"
-	                "                                (non-unique) GID\n"), stderr);
-	(void) fputs (_("  -p, --password PASSWORD       use this encrypted password for the new group\n"), stderr);
-	(void) fputs (_("  -r, --system                  create a system account\n"), stderr);
-	(void) fputs ("\n", stderr);
-	exit (E_USAGE);
+	                "                                (non-unique) GID\n"), usageout);
+	(void) fputs (_("  -p, --password PASSWORD       use this encrypted password for the new group\n"), usageout);
+	(void) fputs (_("  -r, --system                  create a system account\n"), usageout);
+	(void) fputs ("\n", usageout);
+	exit (status);
 }
 
 /*
@@ -412,7 +412,7 @@ static void process_flags (int argc, char **argv)
 			}
 			break;
 		case 'h':
-			usage ();
+			usage (E_SUCCESS);
 			break;
 		case 'K':
 			/*
@@ -444,7 +444,7 @@ static void process_flags (int argc, char **argv)
 			rflg = true;
 			break;
 		default:
-			usage ();
+			usage (E_USAGE);
 		}
 	}
 
@@ -452,7 +452,7 @@ static void process_flags (int argc, char **argv)
 	 * Check the flags consistency
 	 */
 	if (optind != argc - 1) {
-		usage ();
+		usage (E_USAGE);
 	}
 	group_name = argv[optind];
 
@@ -468,7 +468,7 @@ static void check_flags (void)
 {
 	/* -o does not make sense without -g */
 	if (oflg && !gflg) {
-		usage ();
+		usage (E_USAGE);
 	}
 
 	check_new_name ();
diff --git a/src/groupmems.c b/src/groupmems.c
index b16fea3..e06ffdb 100644
--- a/src/groupmems.c
+++ b/src/groupmems.c
@@ -88,7 +88,6 @@ static void remove_user (const char *user,
                          const struct group *grp);
 static void purge_members (const struct group *grp);
 static void display_members (const char *const *members);
-static void usage (void);
 static void process_flags (int argc, char **argv);
 static void check_perms (void);
 static void fail_exit (int code);
@@ -361,7 +360,7 @@ static void display_members (const char *const *members)
 	}
 }
 
-static void usage (void)
+static void usage (int status)
 {
 	(void) fputs (_("Usage: groupmems [options] [action]\n"
 	                "\n"
@@ -372,10 +371,11 @@ static void usage (void)
 	                "Actions:\n"
 	                "  -a, --add username            add username to the members of the group\n"
 	                "  -d, --delete username         remove username from the members of the group\n"
+	                "  -h, --help                    display this help message and exit\n"
 	                "  -p, --purge                   purge all members from the group\n"
 	                "  -l, --list                    list the members of the group\n"
-	                "\n"), stderr);
-	fail_exit (EXIT_USAGE);
+	                "\n"), status ? stderr : stdout);
+	fail_exit (status);
 }
 
 /*
@@ -394,7 +394,7 @@ static void process_flags (int argc, char **argv)
 		{NULL, 0, NULL, '\0'}
 	};
 
-	while ((arg = getopt_long (argc, argv, "a:d:g:lp", long_options,
+	while ((arg = getopt_long (argc, argv, "a:d:g:hlp", long_options,
 	                           &option_index)) != EOF) {
 		switch (arg) {
 		case 'a':
@@ -408,6 +408,8 @@ static void process_flags (int argc, char **argv)
 		case 'g':
 			thisgroup = xstrdup (optarg);
 			break;
+		case 'h':
+			usage (EXIT_SUCCESS);
 		case 'l':
 			list = true;
 			++exclusive;
@@ -417,12 +419,12 @@ static void process_flags (int argc, char **argv)
 			++exclusive;
 			break;
 		default:
-			usage ();
+			usage (EXIT_USAGE);
 		}
 	}
 
 	if ((exclusive > 1) || (optind < argc)) {
-		usage ();
+		usage (EXIT_USAGE);
 	}
 
 	/* local, no need for xgetpwnam */
diff --git a/src/groupmod.c b/src/groupmod.c
index c970ab7..60c77bc 100644
--- a/src/groupmod.c
+++ b/src/groupmod.c
@@ -93,7 +93,6 @@ static bool
     pflg = false;		/* new encrypted password */
 
 /* local function prototypes */
-static void usage (void);
 static void new_grent (struct group *);
 
 #ifdef SHADOWGRP
@@ -113,21 +112,22 @@ static void update_primary_groups (gid_t ogid, gid_t ngid);
  * usage - display usage message and exit
  */
 
-static void usage (void)
+static void usage (int status)
 {
-	(void) fprintf (stderr,
+	FILE *usageout = status ? stderr : stdout;
+	(void) fprintf (usageout,
 	                _("Usage: %s [options] GROUP\n"
 	                  "\n"
 	                  "Options:\n"),
 	                Prog);
-	(void) fputs (_("  -g, --gid GID                 change the group ID to GID\n"), stderr);
-	(void) fputs (_("  -h, --help                    display this help message and exit\n"), stderr);
-	(void) fputs (_("  -n, --new-name NEW_GROUP      change the name to NEW_GROUP\n"), stderr);
-	(void) fputs (_("  -o, --non-unique              allow to use a duplicate (non-unique) GID\n"), stderr);
+	(void) fputs (_("  -g, --gid GID                 change the group ID to GID\n"), usageout);
+	(void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
+	(void) fputs (_("  -n, --new-name NEW_GROUP      change the name to NEW_GROUP\n"), usageout);
+	(void) fputs (_("  -o, --non-unique              allow to use a duplicate (non-unique) GID\n"), usageout);
 	(void) fputs (_("  -p, --password PASSWORD       change the password to this (encrypted)\n"
-	                "                                PASSWORD\n"), stderr);
-	(void) fputs ("\n", stderr);
-	exit (E_USAGE);
+	                "                                PASSWORD\n"), usageout);
+	(void) fputs ("\n", usageout);
+	exit (status);
 }
 
 /*
@@ -362,6 +362,8 @@ static void process_flags (int argc, char **argv)
 				exit (E_BAD_ARG);
 			}
 			break;
+		case 'h':
+			usage (E_SUCCESS);
 		case 'n':
 			nflg = true;
 			group_newname = optarg;
@@ -374,16 +376,16 @@ static void process_flags (int argc, char **argv)
 			pflg = true;
 			break;
 		default:
-			usage ();
+			usage (E_USAGE);
 		}
 	}
 
 	if (oflg && !gflg) {
-		usage ();
+		usage (E_USAGE);
 	}
 
 	if (optind != (argc - 1)) {
-		usage ();
+		usage (E_USAGE);
 	}
 
 	group_name = argv[argc - 1];
diff --git a/src/lastlog.c b/src/lastlog.c
index 4aa81fb..173b654 100644
--- a/src/lastlog.c
+++ b/src/lastlog.c
@@ -71,7 +71,7 @@ static bool bflg = false;	/* print excludes most recent days */
 
 #define	NOW	(time ((time_t *) 0))
 
-static void usage (void)
+static void usage (int status)
 {
 	fputs (_("Usage: lastlog [options]\n"
 	         "\n"
@@ -80,8 +80,8 @@ static void usage (void)
 	         "  -h, --help                    display this help message and exit\n"
 	         "  -t, --time DAYS               print only lastlog records more recent than DAYS\n"
 	         "  -u, --user LOGIN              print lastlog record of the specified LOGIN\n"
-	         "\n"), stderr);
-	exit (EXIT_FAILURE);
+	         "\n"), status ? stderr : stdout);
+	exit (status);
 }
 
 static void print_one (/*@null@*/const struct passwd *pw)
@@ -208,7 +208,7 @@ int main (int argc, char **argv)
 		                         NULL)) != -1) {
 			switch (c) {
 			case 'h':
-				usage ();
+				usage (EXIT_SUCCESS);
 				break;
 			case 't':
 			{
@@ -267,7 +267,7 @@ int main (int argc, char **argv)
 				break;
 			}
 			default:
-				usage ();
+				usage (EXIT_FAILURE);
 				break;
 			}
 		}
@@ -275,7 +275,7 @@ int main (int argc, char **argv)
 			fprintf (stderr,
 			         _("lastlog: unexpected argument: %s\n"),
 			         argv[optind]);
-			usage();
+			usage (EXIT_FAILURE);
 		}
 	}
 
diff --git a/src/newusers.c b/src/newusers.c
index 9da38de..177bcb8 100644
--- a/src/newusers.c
+++ b/src/newusers.c
@@ -92,7 +92,6 @@ static bool gr_locked = false;
 static bool spw_locked = false;
 
 /* local function prototypes */
-static void usage (void);
 static void fail_exit (int);
 static int add_group (const char *, const char *, gid_t *, gid_t);
 static int get_user_id (const char *, uid_t *);
@@ -110,15 +109,16 @@ static void close_files (void);
 /*
  * usage - display usage message and exit
  */
-static void usage (void)
+static void usage (int status)
 {
-	(void) fprintf (stderr,
+	FILE *usageout = status ? stderr : stdout;
+	(void) fprintf (usageout,
 	                _("Usage: %s [options]\n"
 	                  "\n"
 	                  "Options:\n"),
 	                Prog);
 #ifndef USE_PAM
-	(void) fprintf (stderr,
+	(void) fprintf (usageout,
 	                _("  -c, --crypt-method            the crypt method (one of %s)\n"),
 #ifndef USE_SHA_CRYPT
 	                "NONE DES MD5"
@@ -127,18 +127,18 @@ static void usage (void)
 #endif				/* USE_SHA_CRYPT */
 	               );
 #endif				/* !USE_PAM */
-	(void) fputs (_("  -h, --help                    display this help message and exit\n"), stderr);
-	(void) fputs (_("  -r, --system                  create system accounts\n"), stderr);
+	(void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
+	(void) fputs (_("  -r, --system                  create system accounts\n"), usageout);
 #ifndef USE_PAM
 #ifdef USE_SHA_CRYPT
 	(void) fputs (_("  -s, --sha-rounds              number of SHA rounds for the SHA*\n"
 	                "                                crypt algorithms\n"),
-	              stderr);
+	              usageout);
 #endif				/* USE_SHA_CRYPT */
 #endif				/* !USE_PAM */
-	(void) fputs ("\n", stderr);
+	(void) fputs ("\n", usageout);
 
-	exit (EXIT_FAILURE);
+	exit (status);
 }
 
 /*
@@ -548,7 +548,7 @@ static void process_flags (int argc, char **argv)
 	                     long_options, &option_index)) != -1) {
 		switch (c) {
 		case 'h':
-			usage ();
+			usage (EXIT_SUCCESS);
 			break;
 		case 'r':
 			rflg = true;
@@ -565,13 +565,13 @@ static void process_flags (int argc, char **argv)
 				fprintf (stderr,
 				         _("%s: invalid numeric argument '%s'\n"),
 				         Prog, optarg);
-				usage ();
+				usage (EXIT_FAILURE);
 			}
 			break;
 #endif				/* USE_SHA_CRYPT */
 #endif				/* !USE_PAM */
 		default:
-			usage ();
+			usage (EXIT_FAILURE);
 			break;
 		}
 	}
@@ -602,7 +602,7 @@ static void check_flags (void)
 		fprintf (stderr,
 		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-s", "-c");
-		usage ();
+		usage (EXIT_FAILURE);
 	}
 #endif				/* USE_SHA_CRYPT */
 
@@ -618,7 +618,7 @@ static void check_flags (void)
 			fprintf (stderr,
 			         _("%s: unsupported crypt method: %s\n"),
 			         Prog, crypt_method);
-			usage ();
+			usage (EXIT_FAILURE);
 		}
 	}
 #endif				/* !USE_PAM */
diff --git a/src/passwd.c b/src/passwd.c
index 4033951..a2e367f 100644
--- a/src/passwd.c
+++ b/src/passwd.c
@@ -180,7 +180,7 @@ static void usage (int status)
 	         "  -w, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS\n"
 	         "  -x, --maxdays MAX_DAYS        set maximum number of days before password\n"
 	         "                                change to MAX_DAYS\n"
-	         "\n"), stderr);
+	         "\n"), status ? stderr : stdout);
 	exit (status);
 }
 
@@ -811,7 +811,7 @@ int main (int argc, char **argv)
 			{NULL, 0, NULL, '\0'}
 		};
 
-		while ((c = getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
+		while ((c = getopt_long (argc, argv, "adehi:kln:qr:Suw:x:",
 		                         long_options, &option_index)) != -1) {
 			switch (c) {
 			case 'a':
@@ -897,6 +897,8 @@ int main (int argc, char **argv)
 				xflg = true;
 				anyflag = true;
 				break;
+			case 'h':
+				usage (E_SUCCESS);
 			default:
 				usage (E_BAD_ARG);
 			}
diff --git a/src/su.c b/src/su.c
index c4c25a1..29f8317 100644
--- a/src/su.c
+++ b/src/su.c
@@ -323,7 +323,7 @@ static void run_shell (const char *shellstr, char *args[], bool doshell,
 /*
  * usage - print command line syntax and exit
   */
-static void usage (void)
+static void usage (int status)
 {
 	fputs (_("Usage: su [options] [LOGIN]\n"
 	         "\n"
@@ -335,8 +335,8 @@ static void usage (void)
 	         "  --preserve-environment        do not reset environment variables, and\n"
 	         "                                keep the same shell\n"
 	         "  -s, --shell SHELL             use SHELL instead of the default in passwd\n"
-	         "\n"), stderr);
-	exit (E_USAGE);
+	         "\n"), status ? stderr : stdout);
+	exit (status);
 }
 
 /*
@@ -421,7 +421,7 @@ int main (int argc, char **argv)
 				command = optarg;
 				break;
 			case 'h':
-				usage ();
+				usage (E_SUCCESS);
 				break;
 			case 'l':
 				fakelogin = true;
@@ -438,7 +438,7 @@ int main (int argc, char **argv)
 				shellstr = optarg;
 				break;
 			default:
-				usage ();	/* NOT REACHED */
+				usage (E_USAGE);	/* NOT REACHED */
 			}
 		}
 
diff --git a/src/useradd.c b/src/useradd.c
index e36a8d9..988c5bd 100644
--- a/src/useradd.c
+++ b/src/useradd.c
@@ -179,7 +179,6 @@ static void get_defaults (void);
 static void show_defaults (void);
 static int set_defaults (void);
 static int get_groups (char *);
-static void usage (void);
 static void new_pwent (struct passwd *);
 #ifdef WITH_SELINUX
 static void selinux_update_mapping (void);
@@ -681,45 +680,46 @@ static int get_groups (char *list)
 /*
  * usage - display usage message and exit
  */
-static void usage (void)
+static void usage (int status)
 {
-	(void) fprintf (stderr,
+	FILE *usageout = status ? stderr : stdout;
+	(void) fprintf (usageout,
 	                _("Usage: useradd [options] LOGIN\n"
 	                  "\n"
 	                  "Options:\n"),
 	                Prog);
 	(void) fputs (_("  -b, --base-dir BASE_DIR       base directory for the home directory of the\n"
-	                "                                new account\n"), stderr);
-	(void) fputs (_("  -c, --comment COMMENT         GECOS field of the new account\n"), stderr);
-	(void) fputs (_("  -d, --home-dir HOME_DIR       home directory of the new account\n"), stderr);
-	(void) fputs (_("  -D, --defaults                print or change default useradd configuration\n"), stderr);
-	(void) fputs (_("  -e, --expiredate EXPIRE_DATE  expiration date of the new account\n"), stderr);
-	(void) fputs (_("  -f, --inactive INACTIVE       password inactivity period of the new account\n"), stderr);
+	                "                                new account\n"), usageout);
+	(void) fputs (_("  -c, --comment COMMENT         GECOS field of the new account\n"), usageout);
+	(void) fputs (_("  -d, --home-dir HOME_DIR       home directory of the new account\n"), usageout);
+	(void) fputs (_("  -D, --defaults                print or change default useradd configuration\n"), usageout);
+	(void) fputs (_("  -e, --expiredate EXPIRE_DATE  expiration date of the new account\n"), usageout);
+	(void) fputs (_("  -f, --inactive INACTIVE       password inactivity period of the new account\n"), usageout);
 	(void) fputs (_("  -g, --gid GROUP               name or ID of the primary group of the new\n"
-	                "                                account\n"), stderr);
+	                "                                account\n"), usageout);
 	(void) fputs (_("  -G, --groups GROUPS           list of supplementary groups of the new\n"
-	                "                                account\n"), stderr);
-	(void) fputs (_("  -h, --help                    display this help message and exit\n"), stderr);
-	(void) fputs (_("  -k, --skel SKEL_DIR           use this alternative skeleton directory\n"), stderr);
-	(void) fputs (_("  -K, --key KEY=VALUE           override /etc/login.defs defaults\n"), stderr);
+	                "                                account\n"), usageout);
+	(void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
+	(void) fputs (_("  -k, --skel SKEL_DIR           use this alternative skeleton directory\n"), usageout);
+	(void) fputs (_("  -K, --key KEY=VALUE           override /etc/login.defs defaults\n"), usageout);
 	(void) fputs (_("  -l, --no-log-init             do not add the user to the lastlog and\n"
-	                "                                faillog databases\n"), stderr);
-	(void) fputs (_("  -m, --create-home             create the user's home directory\n"), stderr);
-	(void) fputs (_("  -M, --no-create-home          do not create the user's home directory\n"), stderr);
+	                "                                faillog databases\n"), usageout);
+	(void) fputs (_("  -m, --create-home             create the user's home directory\n"), usageout);
+	(void) fputs (_("  -M, --no-create-home          do not create the user's home directory\n"), usageout);
 	(void) fputs (_("  -N, --no-user-group           do not create a group with the same name as\n"
-	                "                                the user\n"), stderr);
+	                "                                the user\n"), usageout);
 	(void) fputs (_("  -o, --non-unique              allow to create users with duplicate\n"
-	                "                                (non-unique) UID\n"), stderr);
-	(void) fputs (_("  -p, --password PASSWORD       encrypted password of the new account\n"), stderr);
-	(void) fputs (_("  -r, --system                  create a system account\n"), stderr);
-	(void) fputs (_("  -s, --shell SHELL             login shell of the new account\n"), stderr);
-	(void) fputs (_("  -u, --uid UID                 user ID of the new account\n"), stderr);
-	(void) fputs (_("  -U, --user-group              create a group with the same name as the user\n"), stderr);
+	                "                                (non-unique) UID\n"), usageout);
+	(void) fputs (_("  -p, --password PASSWORD       encrypted password of the new account\n"), usageout);
+	(void) fputs (_("  -r, --system                  create a system account\n"), usageout);
+	(void) fputs (_("  -s, --shell SHELL             login shell of the new account\n"), usageout);
+	(void) fputs (_("  -u, --uid UID                 user ID of the new account\n"), usageout);
+	(void) fputs (_("  -U, --user-group              create a group with the same name as the user\n"), usageout);
 #ifdef WITH_SELINUX
-	(void) fputs (_("  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping\n"), stderr);
+	(void) fputs (_("  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping\n"), usageout);
 #endif
-	(void) fputs ("\n", stderr);
-	exit (E_USAGE);
+	(void) fputs ("\n", usageout);
+	exit (status);
 }
 
 /*
@@ -989,9 +989,9 @@ static void process_flags (int argc, char **argv)
 		};
 		while ((c = getopt_long (argc, argv,
 #ifdef WITH_SELINUX
-		                         "b:c:d:De:f:g:G:k:K:lmMNop:rs:u:UZ:",
+		                         "b:c:d:De:f:g:G:hk:K:lmMNop:rs:u:UZ:",
 #else
-		                         "b:c:d:De:f:g:G:k:K:lmMNop:rs:u:U",
+		                         "b:c:d:De:f:g:G:hk:K:lmMNop:rs:u:U",
 #endif
 		                         long_options, NULL)) != -1) {
 			switch (c) {
@@ -1029,7 +1029,7 @@ static void process_flags (int argc, char **argv)
 				break;
 			case 'D':
 				if (anyflag) {
-					usage ();
+					usage (E_USAGE);
 				}
 				Dflg = true;
 				break;
@@ -1066,7 +1066,7 @@ static void process_flags (int argc, char **argv)
 					fprintf (stderr,
 					         _("%s: invalid numeric argument '%s'\n"),
 					         Prog, optarg);
-					usage ();
+					usage (E_USAGE);
 				}
 				/*
 				 * -f -1 is allowed
@@ -1106,7 +1106,7 @@ static void process_flags (int argc, char **argv)
 				Gflg = true;
 				break;
 			case 'h':
-				usage ();
+				usage (E_SUCCESS);
 				break;
 			case 'k':
 				def_template = optarg;
@@ -1201,7 +1201,7 @@ static void process_flags (int argc, char **argv)
 				break;
 #endif
 			default:
-				usage ();
+				usage (E_USAGE);
 			}
 			anyflag = true;
 		}
@@ -1220,31 +1220,31 @@ static void process_flags (int argc, char **argv)
 		fprintf (stderr,
 		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-o", "-u");
-		usage ();
+		usage (E_USAGE);
 	}
 	if (kflg && !mflg) {
 		fprintf (stderr,
 		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-k", "-m");
-		usage ();
+		usage (E_USAGE);
 	}
 	if (Uflg && gflg) {
 		fprintf (stderr,
 		         _("%s: options %s and %s conflict\n"),
 		         Prog, "-U", "-g");
-		usage ();
+		usage (E_USAGE);
 	}
 	if (Uflg && Nflg) {
 		fprintf (stderr,
 		         _("%s: options %s and %s conflict\n"),
 		         Prog, "-U", "-N");
-		usage ();
+		usage (E_USAGE);
 	}
 	if (mflg && Mflg) {
 		fprintf (stderr,
 		         _("%s: options %s and %s conflict\n"),
 		         Prog, "-m", "-M");
-		usage ();
+		usage (E_USAGE);
 	}
 
 	/*
@@ -1253,15 +1253,15 @@ static void process_flags (int argc, char **argv)
 	 */
 	if (Dflg) {
 		if (optind != argc) {
-			usage ();
+			usage (E_USAGE);
 		}
 
 		if (uflg || oflg || Gflg || dflg || cflg || mflg) {
-			usage ();
+			usage (E_USAGE);
 		}
 	} else {
 		if (optind != argc - 1) {
-			usage ();
+			usage (E_USAGE);
 		}
 
 		user_name = argv[optind];
diff --git a/src/userdel.c b/src/userdel.c
index bfa9129..8b2031b 100644
--- a/src/userdel.c
+++ b/src/userdel.c
@@ -94,7 +94,6 @@ static bool gr_locked   = false;
 static bool spw_locked  = false;
 
 /* local function prototypes */
-static void usage (void);
 static void update_groups (void);
 static void close_files (void);
 static void fail_exit (int);
@@ -111,7 +110,7 @@ static int remove_mailbox (void);
 /*
  * usage - display usage message and exit
  */
-static void usage (void)
+static void usage (int status)
 {
 	fputs (_("Usage: userdel [options] LOGIN\n"
 	         "\n"
@@ -120,8 +119,8 @@ static void usage (void)
 	         "                                even if not owned by user\n"
 	         "  -h, --help                    display this help message and exit\n"
 	         "  -r, --remove                  remove home directory and mail spool\n"
-	         "\n"), stderr);
-	exit (E_USAGE);
+	         "\n"), status ? stderr : stdout);
+	exit (status);
 }
 
 /*
@@ -774,17 +773,19 @@ int main (int argc, char **argv)
 			case 'f':	/* force remove even if not owned by user */
 				fflg = true;
 				break;
+			case 'h':
+				usage (E_SUCCESS);
 			case 'r':	/* remove home dir and mailbox */
 				rflg = true;
 				break;
 			default:
-				usage ();
+				usage (E_USAGE);
 			}
 		}
 	}
 
 	if ((optind + 1) != argc) {
-		usage ();
+		usage (E_USAGE);
 	}
 
 	OPENLOG ("userdel");
diff --git a/src/usermod.c b/src/usermod.c
index 6716aaf..3901a46 100644
--- a/src/usermod.c
+++ b/src/usermod.c
@@ -149,7 +149,6 @@ static bool sgr_locked = false;
 static void date_to_str (char *buf, size_t maxsize,
                          long int date, const char *negativ);
 static int get_groups (char *);
-static void usage (void);
 static void new_pwent (struct passwd *);
 #ifdef WITH_SELINUX
 static void selinux_update_mapping (void);
@@ -300,9 +299,9 @@ static int get_groups (char *list)
 /*
  * usage - display usage message and exit
  */
-static void usage (void)
+static void usage (int status)
 {
-	fprintf (stderr,
+	fprintf (status ? stderr : stdout,
 	         _("Usage: usermod [options] LOGIN\n"
 	         "\n"
 	         "Options:\n"
@@ -334,7 +333,7 @@ static void usage (void)
 	         ""
 #endif
 	         );
-	exit (E_USAGE);
+	exit (status);
 }
 
 /*
@@ -815,7 +814,7 @@ static void process_flags (int argc, char **argv)
 	bool anyflag = false;
 
 	if ((1 == argc) || ('-' == argv[argc - 1][0])) {
-		usage ();
+		usage (E_USAGE);
 	}
 
 	{
@@ -955,7 +954,7 @@ static void process_flags (int argc, char **argv)
 					fprintf (stderr,
 					         _("%s: invalid numeric argument '%s'\n"),
 					         Prog, optarg);
-					usage ();
+					usage (E_USAGE);
 				}
 				fflg = true;
 				break;
@@ -976,6 +975,8 @@ static void process_flags (int argc, char **argv)
 				}
 				Gflg = true;
 				break;
+			case 'h':
+				usage (E_SUCCESS);
 			case 'l':
 				if (!is_valid_user_name (optarg)) {
 					fprintf (stderr,
@@ -1036,7 +1037,7 @@ static void process_flags (int argc, char **argv)
 				break;
 #endif
 			default:
-				usage ();
+				usage (E_USAGE);
 			}
 			anyflag = true;
 		}
@@ -1092,14 +1093,14 @@ static void process_flags (int argc, char **argv)
 	}
 
 	if (optind != argc - 1) {
-		usage ();
+		usage (E_USAGE);
 	}
 
 	if (aflg && (!Gflg)) {
 		fprintf (stderr,
 		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-a", "-G");
-		usage ();
+		usage (E_USAGE);
 		exit (E_USAGE);
 	}
 
@@ -1107,7 +1108,7 @@ static void process_flags (int argc, char **argv)
 		fprintf (stderr,
 		         _("%s: the -L, -p, and -U flags are exclusive\n"),
 		         Prog);
-		usage ();
+		usage (E_USAGE);
 		exit (E_USAGE);
 	}
 
@@ -1115,7 +1116,7 @@ static void process_flags (int argc, char **argv)
 		fprintf (stderr,
 		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-o", "-u");
-		usage ();
+		usage (E_USAGE);
 		exit (E_USAGE);
 	}
 
@@ -1123,7 +1124,7 @@ static void process_flags (int argc, char **argv)
 		fprintf (stderr,
 		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-m", "-d");
-		usage ();
+		usage (E_USAGE);
 		exit (E_USAGE);
 	}
 
diff --git a/src/vipw.c b/src/vipw.c
index bc77b97..1d7bba0 100644
--- a/src/vipw.c
+++ b/src/vipw.c
@@ -64,7 +64,6 @@ static int (*unlock) (void);
 static bool quiet = false;
 
 /* local function prototypes */
-static void usage (void);
 static int create_backup_file (FILE *, const char *, struct stat *);
 static void vipwexit (const char *msg, int syserr, int ret);
 static void vipwedit (const char *, int (*)(void), int (*)(void));
@@ -72,7 +71,7 @@ static void vipwedit (const char *, int (*)(void), int (*)(void));
 /*
  * usage - display usage message and exit
  */
-static void usage (void)
+static void usage (int status)
 {
 	(void) 
 	fputs (_("Usage: vipw [options]\n"
@@ -83,8 +82,8 @@ static void usage (void)
 	         "  -p, --passwd                  edit passwd database\n"
 	         "  -q, --quiet                   quiet mode\n"
 	         "  -s, --shadow                  edit shadow or gshadow database\n"
-	         "\n"), stderr);
-	exit (E_USAGE);
+	         "\n"), status ? stderr : stdout);
+	exit (status);
 }
 
 /*
@@ -353,7 +352,7 @@ int main (int argc, char **argv)
 				do_vipw = false;
 				break;
 			case 'h':
-				usage ();
+				usage (E_SUCCESS);
 				break;
 			case 'p':
 				do_vipw = true;
@@ -365,7 +364,7 @@ int main (int argc, char **argv)
 				editshadow = true;
 				break;
 			default:
-				usage ();
+				usage (E_USAGE);
 			}
 		}
 	}
-- 
1.6.4




More information about the Pkg-shadow-devel mailing list