summaryrefslogtreecommitdiff
path: root/src/sleep.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-10-12 01:52:24 +0000
committerJim Meyering <jim@meyering.net>1993-10-12 01:52:24 +0000
commit87fa23e6417d7d1938b72e872d779ae7225a5aa4 (patch)
tree0fcc68f9cdf7315d09d5836df0f261e3d6b8c13a /src/sleep.c
parentf12b53b2ce8f0bb0dd28a290f9b27490ef4599a9 (diff)
downloadcoreutils-87fa23e6417d7d1938b72e872d779ae7225a5aa4.tar.xz
merge with 1.8.1b
Diffstat (limited to 'src/sleep.c')
-rw-r--r--src/sleep.c46
1 files changed, 46 insertions, 0 deletions
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 <stdio.h>
#include <sys/types.h>
+#include <getopt.h>
+
+#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]);