Last Updated: February 25, 2016
·
1.987K
· afeld

Run a bash command until it fails

Useful for finding flaky tests/specs, etc. Modify the COMMAND below and paste into your terminal:

# tweak these
TRIES=5
COMMAND="bundle exec rspec"

# tweaked from http://unix.stackexchange.com/a/82602
n=0
until [ $n -ge $TRIES ]
do
  $COMMAND || break
  n=$[$n+1]
done