repeat.git


repeat

~ repeat a command n times
git clone https://github.com/djnnvx/repeat.git
log | files | refs | archive | README

main.c (508B)

      1 
      2 #include "repeat.h"
      3 
      4 int main(int ac, char **av) {
      5     if (ac < 3) {
      6         fprintf(stderr, "Usage: repeat <number> <command> [args...]\n");
      7         return 1;
      8     }
      9     int nb_executions = parse_positive_int(av[1]);
     10     if (nb_executions < 1) {
     11         fprintf(stderr, "First argument must be a positive number\n");
     12         return 1;
     13     }
     14     for (int i = 0; i < nb_executions; ++i) {
     15         int status = execute_command(&av[2]);
     16         if (status != 0)
     17             return status;
     18     }
     19     return 0;
     20 }