diff options
Diffstat (limited to 'src/logname.c')
-rw-r--r-- | src/logname.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/logname.c b/src/logname.c index 9a95bceee..a75208d10 100644 --- a/src/logname.c +++ b/src/logname.c @@ -50,11 +50,26 @@ static struct option const long_options[] = }; static void -usage () +usage (status) + int status; { - fprintf (stderr, "Usage: %s [{--help,--version}]\n", + fprintf (status == 0 ? stdout : stderr, "\ +Usage: %s [OPTION]...\n\ +", program_name); - exit (1); + + if (status != 0) + fprintf (stderr, "\nTry `%s --help' for more information.\n", + program_name); + else + + printf ("\ +\n\ + --help display this help and exit\n\ + --version output version information and exit\n\ +"); + + exit (status); } void @@ -75,7 +90,7 @@ main (argc, argv) break; default: - usage (); + usage (1); } } @@ -86,10 +101,10 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (argc - optind != 0) - usage (); + usage (1); /* POSIX.2 requires using getlogin (or equivalent code). */ cp = getlogin (); |