summaryrefslogtreecommitdiff
path: root/do-until
diff options
context:
space:
mode:
Diffstat (limited to 'do-until')
-rwxr-xr-xdo-until10
1 files changed, 8 insertions, 2 deletions
diff --git a/do-until b/do-until
index 1f60200..be6efee 100755
--- a/do-until
+++ b/do-until
@@ -14,9 +14,12 @@ import time
def do_until(options, argv):
- while True:
+ tries = 0
+ while options.max_tries == 0 or tries < options.max_tries:
+ tries += 1
if options.verbose:
- sys.stderr.write("do-until: executing: %s\n" % " ".join(argv))
+ sys.stderr.write("do-until: attempt #%d: %s\n" %
+ (tries, " ".join(argv)))
if options.no_act:
sys.stderr.write("do-until: not running command, pretending it "
"works anyway\n")
@@ -41,6 +44,9 @@ def parse_args(args):
parser.add_option("--sleep", type="int", default=1, metavar="SECS",
help="Wait SECS seconds before re-trying a command. "
"(Default is %default.)")
+ parser.add_option("--max-tries", type="int", default=0, metavar="COUNT",
+ help="Try at most COUNT times, with 0 meaning forever. "
+ "(Default is %default.)")
options, argv = parser.parse_args(args)