1 /* sleep - delay for a specified amount of time.
2 Copyright (C) 84, 1991-1997, 1999 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #include <sys/types.h>
25 #include "long-options.h"
27 /* The official name of this program (e.g., no `g' prefix). */
28 #define PROGRAM_NAME "sleep"
30 #define AUTHORS "FIXME: unknown"
32 static long argdecode
PARAMS ((const char *s
));
34 /* The name by which this program was run. */
37 static struct option
const long_options
[] =
46 fprintf (stderr
, _("Try `%s --help' for more information.\n"),
50 printf (_("Usage: %s [OPTION]... NUMBER[SUFFIX]\n"), program_name
);
52 Pause for NUMBER seconds.\n\
53 SUFFIX may be s to keep seconds, m for minutes, h for hours or d for days.\n\
55 --help display this help and exit\n\
56 --version output version information and exit\n"));
57 puts (_("\nReport bugs to <bug-sh-utils@gnu.org>."));
63 main (int argc
, char **argv
)
69 program_name
= argv
[0];
70 setlocale (LC_ALL
, "");
71 bindtextdomain (PACKAGE
, LOCALEDIR
);
74 parse_long_options (argc
, argv
, PROGRAM_NAME
, GNU_PACKAGE
, VERSION
,
77 while ((c
= getopt_long (argc
, argv
, "", long_options
, NULL
)) != -1)
91 error (0, 0, _("too few arguments"));
95 for (i
= 1; i
< argc
; i
++)
96 seconds
+= argdecode (argv
[i
]);
104 argdecode (const char *s
)
107 register const char *p
= s
;
111 while ((c
= *p
++) >= '0' && c
<= '9')
112 value
= value
* 10 + c
- '0';
125 value
*= 60 * 60 * 24;
132 error (1, 0, _("invalid time interval `%s'"), s
);