NAME
try_repeat
—
Run a command 'n' times, exiting early
if the command returns non-zero
SYNOPSIS
try_repeat |
[-v ] count
command [options ...] |
DESCRIPTION
try_repeat
tries to run
command at most count times,
exiting early if command exits with a non-zero exit
code. This is useful when trying to find intermittent failures in
command.
The options are as follows:
-v
- Print out the iteration number before executing command.
try_repeat
exits with the exit code of the
last iteration of command.
EXAMPLES
$ try_repeat 3 ls
/etc/motd
/etc/motd
/etc/motd
/etc/motd
$ echo $?
0
$ try_repeat 3 ls
/doesntexist
ls: /doesntexist:
such file or directory
$ echo $?
1
$ try_repeat -v 3 ls
/etc/motd
===> 1: ls /etc/motd
/etc/motd
===> 2: ls /etc/motd
/etc/motd
===> 3: ls /etc/motd
/etc/motd
AUTHORS
try_repeat
was written by
Laurence Tratt
https://tratt.net/laurie/.