2013-09-04 10:27:29 +00:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2014-06-30 18:03:41 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2013-09-04 10:27:29 +00:00
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
eprintf("usage: %s [-t] [-n interval] command\n", argv0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
char cmd[BUFSIZ];
|
|
|
|
int i, interval = 2;
|
|
|
|
|
|
|
|
ARGBEGIN {
|
|
|
|
case 't':
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
/* Only whole seconds for now */
|
|
|
|
interval = estrtol(EARGF(usage()), 10);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
} ARGEND;
|
|
|
|
|
|
|
|
if (argc < 1)
|
|
|
|
usage();
|
|
|
|
|
|
|
|
strlcpy(cmd, argv[0], sizeof(cmd));
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
strlcat(cmd, " ", sizeof(cmd));
|
|
|
|
strlcat(cmd, argv[i], sizeof(cmd));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
2014-02-14 13:38:56 +00:00
|
|
|
printf("\x1b[2J\x1b[H"); /* clear */
|
2013-09-04 10:27:29 +00:00
|
|
|
fflush(NULL);
|
|
|
|
system(cmd);
|
|
|
|
sleep(interval);
|
|
|
|
}
|
2013-10-07 18:11:40 +00:00
|
|
|
return EXIT_SUCCESS;
|
2013-09-04 10:27:29 +00:00
|
|
|
}
|