From 87fa23e6417d7d1938b72e872d779ae7225a5aa4 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 12 Oct 1993 01:52:24 +0000 Subject: merge with 1.8.1b --- src/sleep.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/sleep.c') diff --git a/src/sleep.c b/src/sleep.c index 1551eeaa8..2858ff42f 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -17,6 +17,9 @@ #include #include +#include + +#include "version.h" #include "system.h" void error (); @@ -26,6 +29,27 @@ static long argdecode (); /* The name by which this program was run. */ char *program_name; +/* If non-zero, display usage information and exit. */ +static int show_help; + +/* If non-zero, print the version on standard output and exit. */ +static int show_version; + +static struct option const long_options[] = +{ + {"help", no_argument, &show_help, 1}, + {"version", no_argument, &show_version, 1}, + {0, 0, 0, 0} +}; + +static void +usage () +{ + fprintf (stderr, "Usage: %s [{--help,--version}] number[smhd]...\n", + program_name); + exit (1); +} + void main (argc, argv) int argc; @@ -33,9 +57,31 @@ main (argc, argv) { int i; unsigned seconds = 0; + int c; program_name = argv[0]; + while ((c = getopt_long (argc, argv, "", long_options, (int *) 0)) != EOF) + { + switch (c) + { + case 0: + break; + + default: + usage (); + } + } + + if (show_version) + { + printf ("%s\n", version_string); + exit (0); + } + + if (show_help) + usage (); + if (argc == 1) { fprintf (stderr, "Usage: %s number[smhd]...\n", argv[0]); -- cgit v1.2.3-70-g09d2