30 lines
566 B
C
30 lines
566 B
C
#include <stdio.h>
|
|
#include <limits.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include "duration.h"
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
int opt;
|
|
while ((opt = getopt(argc, argv, "")) != -1 || argc == 1) {
|
|
puts("sleep [num[SUFFIX]] / [inf]\nSUFFIXES:\n\tm - minute\n\th - hour\n\td - days");
|
|
return 0;
|
|
}
|
|
|
|
argv += optind;
|
|
argc -= optind;
|
|
|
|
if (!strncasecmp(argv[0], "inf", 3))
|
|
while (1)
|
|
sleep(INT_MAX);
|
|
|
|
unsigned long long usec = 0;
|
|
for (int i = 0; i < argc; i++)
|
|
usec += mu_parse_duration(argv[i]);
|
|
|
|
usleep(usec);
|
|
return 0;
|
|
}
|