add ttd: run a command until it fails.
authorColin Patrick Mccabe <cmccabe@alumni.cmu.edu>
Fri, 28 Mar 2014 17:55:32 +0000 (10:55 -0700)
committerColin Patrick Mccabe <cmccabe@alumni.cmu.edu>
Fri, 28 Mar 2014 17:55:32 +0000 (10:55 -0700)
Signed-off-by: Colin McCabe <cmccabe@alumni.cmu.edu>

ttd [new file with mode: 0755]

diff --git a/ttd b/ttd
new file mode 100755 (executable)
index 0000000..b8ba46c
--- /dev/null
+++ b/ttd
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+#
+# ttd: run a command until it fails.
+#
+# usage: ttd [num-runs] command
+#
+
+NUM_RUNS=$1
+shift
+CMD="${@}"
+for i in `seq 1 $NUM_RUNS`; do
+    ${CMD}
+    if [ $? -ne 0 ]; then
+        exit 1
+    fi
+done
+
+echo "*** SUCCESSFULLY RAN ${NUM_RUNS} RUNS ***"