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"),
51 Usage: %s NUMBER[SUFFIX]\n\
53 Pause for NUMBER seconds.\n\
54 SUFFIX may be s for seconds (the default), m for minutes,\n\
55 h for hours or d for days.\n\
57 --help display this help and exit\n\
58 --version output version information and exit\n\
60 program_name
, program_name
);
61 puts (_("\nReport bugs to <bug-sh-utils@gnu.org>."));
67 main (int argc
, char **argv
)
73 program_name
= argv
[0];
74 setlocale (LC_ALL
, "");
75 bindtextdomain (PACKAGE
, LOCALEDIR
);
78 parse_long_options (argc
, argv
, PROGRAM_NAME
, GNU_PACKAGE
, VERSION
,
81 while ((c
= getopt_long (argc
, argv
, "", long_options
, NULL
)) != -1)
95 error (0, 0, _("too few arguments"));
99 for (i
= 1; i
< argc
; i
++)
100 seconds
+= argdecode (argv
[i
]);
108 argdecode (const char *s
)
111 register const char *p
= s
;
115 while ((c
= *p
++) >= '0' && c
<= '9')
116 value
= value
* 10 + c
- '0';
129 value
*= 60 * 60 * 24;
136 error (1, 0, _("invalid time interval `%s'"), s
);