Last active
December 11, 2015 15:38
-
-
Save Heimdell/4621879 to your computer and use it in GitHub Desktop.
Do it again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(int argc, char *argv[]) { | |
int count = 10, silent = 0; | |
char * command = 0; | |
char letter; | |
while ((letter = getopt_long(argc, argv, "n:c:s")) != -1) { | |
switch (letter) { | |
case 'n': | |
count = atoi(optarg); | |
break; | |
case 'c': | |
command = optarg; | |
break; | |
case 's': | |
silent = 1; | |
} | |
} | |
if (!command) { | |
printf("USAGE: retry [-n <number>] -c <command> [-s]\n"); | |
} | |
int result = -1; | |
while (count--) { | |
result = system(command); | |
if (!result) break; | |
if (!silent) { | |
printf("\nexecution result was %d\n%d more times...\n\n", result, count); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment