Repeatedly run a shell command until it fails?

I’ve written a fuzzy test that fails unreliably. I’ve added some debug code, but now I want to run the test until it fails so I can gather the debug output.

I’ve setup the test so I can run it using:

./runtest

My current solution is to write an untilfail script:

#!/bin/bash
$@
while [ $? -eq 0 ]; do
    $@
done

Then use it:

untilfail ./runtest

Is there a simpler solution?

5 Answers
5

Leave a Comment