Skip to content

Commit d865992

Browse files
committed
Update README and man pages.
Clarify the syntax with -- to avoid problems with options in the repeated command. Add detail how to use the staggered option.
1 parent 5e0a68f commit d865992

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

INSTALL

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Installation Instructions
22
*************************
33

4-
Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
5-
Foundation, Inc.
4+
Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free
5+
Software Foundation, Inc.
66

77
Copying and distribution of this file, with or without modification,
88
are permitted in any medium without royalty provided the copyright
@@ -225,7 +225,7 @@ order to use an ANSI C compiler:
225225

226226
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
227227

228-
HP-UX 'make' updates targets which have the same time stamps as their
228+
HP-UX 'make' updates targets which have the same timestamps as their
229229
prerequisites, which makes it generally unusable when shipped generated
230230
files such as 'configure' are involved. Use GNU 'make' instead.
231231

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ sudo apt-get install retry
2929

3030
# example
3131
```
32-
~$ retry --until=success false
32+
~$ retry --until=success -- false
3333
retry: 'false' returned 1, backing off for 10 seconds and trying again...
3434
retry: 'false' returned 1, backing off for 10 seconds and trying again...
3535
retry: 'false' returned 1, backing off for 10 seconds and trying again...
@@ -38,15 +38,15 @@ retry: 'false' returned 1, backing off for 10 seconds and trying again...
3838

3939
# more complex example
4040
```
41-
~$ retry curl --fail http://localhost/entities | \
41+
~$ retry -- curl --fail http://localhost/entities | \
4242
jq ... | \
43-
retry curl --fail -X POST http://localhost/resource | \
43+
retry -- curl --fail -X POST http://localhost/resource | \
4444
logger -t resource-init
4545
```
4646

4747
# staggered delays
4848
```
49-
~$ retry --until=success --delay "1,2,4,8,16,32,64" false
49+
~$ retry --until=success --delay "1,2,4,8,16,32,64" -- false
5050
retry: false returned 1, backing off for 1 second and trying again...
5151
retry: false returned 1, backing off for 2 seconds and trying again...
5252
retry: false returned 1, backing off for 4 seconds and trying again...

retry.c

+23-7
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int help(const char *name, const char *msg, int code)
151151
"EXAMPLES\n"
152152
" In this basic example, we repeat the command forever.\n"
153153
"\n"
154-
"\t~$ retry --until=success false\n"
154+
"\t~$ retry --until=success -- false\n"
155155
"\tretry: 'false' returned 1, backing off for 10 seconds and trying again...\n"
156156
"\tretry: 'false' returned 1, backing off for 10 seconds and trying again...\n"
157157
"\tretry: 'false' returned 1, backing off for 10 seconds and trying again...\n"
@@ -162,11 +162,27 @@ static int help(const char *name, const char *msg, int code)
162162
" passed once and once only to the next element in the\n"
163163
" pipeline.\n"
164164
"\n"
165-
"\t~$ retry curl --fail http://localhost/entities | \\\\ \n"
165+
"\t~$ retry -- curl --fail http://localhost/entities | \\\\ \n"
166166
"\tjq ... | \\\\ \n"
167-
"\tretry curl --fail -X POST http://localhost/resource | \\\\ \n"
167+
"\tretry -- curl --fail -X POST http://localhost/resource | \\\\ \n"
168168
"\tlogger -t resource-init\n"
169169
"\n"
170+
" In this example, we stagger each delay exponentially\n"
171+
" until 64 seconds, which is then repeated until\n"
172+
" interrupted.\n"
173+
"\n"
174+
"\t~$ retry --until=success --delay \"1,2,4,8,16,32,64\" -- false\n"
175+
"\tretry: false returned 1, backing off for 1 second and trying again...\n"
176+
"\tretry: false returned 1, backing off for 2 seconds and trying again...\n"
177+
"\tretry: false returned 1, backing off for 4 seconds and trying again...\n"
178+
"\tretry: false returned 1, backing off for 8 seconds and trying again...\n"
179+
"\tretry: false returned 1, backing off for 16 seconds and trying again...\n"
180+
"\tretry: false returned 1, backing off for 32 seconds and trying again...\n"
181+
"\tretry: false returned 1, backing off for 64 seconds and trying again...\n"
182+
"\tretry: false returned 1, backing off for 64 seconds and trying again...\n"
183+
"\tretry: false returned 1, backing off for 64 seconds and trying again...\n"
184+
"\t^C\n"
185+
"\n"
170186
"AUTHOR\n"
171187
" Graham Leggett <minfrin@sharp.fm>\n"
172188
"", msg ? msg : "", n, n);
@@ -402,9 +418,9 @@ int main (int argc, char **argv)
402418
delay = optarg;
403419

404420
do {
405-
errno = 0;
421+
errno = 0;
406422

407-
d = strtol(optarg, &optarg, 10);
423+
d = strtol(optarg, &optarg, 10);
408424

409425
if (errno || (optarg[0] && optarg[0] != ',') || d < 0) {
410426
return help(name, "Delay(s) must be bigger or equal to 0.\n", EXIT_FAILURE);
@@ -580,10 +596,10 @@ int main (int argc, char **argv)
580596
memset(&pumps[STDOUT_FD], 0, sizeof(pump_t));
581597

582598
if (delay[0]) {
583-
d = strtol(delay, &delay, 10);
599+
d = strtol(delay, &delay, 10);
584600
}
585601
if (delay[0] == ',') {
586-
delay++;
602+
delay++;
587603
}
588604

589605
if (d) {

0 commit comments

Comments
 (0)