@@ -120,7 +120,7 @@ static int help(const char *name, const char *msg, int code)
120120 " when repeat has backed off. Defaults to the\n"
121121 " command name.\n"
122122 "\n"
123- " -t times, --times=times The number of times to retry \n"
123+ " -t times, --times=times Total number of times to try \n"
124124 " the command. By default we try forever.\n"
125125 "\n"
126126 " -u criteria, --until=criteria Keep repeating the command until any one\n"
@@ -183,6 +183,13 @@ static int help(const char *name, const char *msg, int code)
183183 "\tretry: false returned 1, backing off for 64 seconds and trying again...\n"
184184 "\t^C\n"
185185 "\n"
186+ " In this example, we try three times before giving up.\n"
187+ "\n"
188+ "\t~$ retry --times=3 -- false\n"
189+ "\tretry: false returned 1, backing off for 10 seconds and trying again...\n"
190+ "\tretry: false returned 1, backing off for 10 seconds and trying again...\n"
191+ "\tretry: false returned 1, giving up.\n"
192+ "\n"
186193 "AUTHOR\n"
187194 " Graham Leggett <[email protected] >\n" 188195 "" , msg ? msg : "" , n , n );
@@ -595,6 +602,14 @@ int main (int argc, char **argv)
595602 free (pumps [STDOUT_FD ].base );
596603 memset (& pumps [STDOUT_FD ], 0 , sizeof (pump_t ));
597604
605+ /* last try? give up */
606+ if (times == 1 ) {
607+ fprintf (stderr ,
608+ "%s: %s returned %d, giving up.\n" ,
609+ name , message ? message : argv [optind ], status );
610+ break ;
611+ }
612+
598613 if (delay [0 ]) {
599614 d = strtol (delay , & delay , 10 );
600615 }
0 commit comments