OSSP CVS Repository

ossp - Check-in [4765]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4765
Date: 2004-Oct-24 20:59:45 (local)
2004-Oct-24 18:59:45 (UTC)
User:rse
Branch:
Comment: add useful repeat command
Tickets:
Inspections:
Files:
ossp-pkg/due/.due/due.util.sh      1.3 -> 1.4     21 inserted, 0 deleted

ossp-pkg/due/.due/due.util.sh 1.3 -> 1.4

--- due.util.sh  2004/10/22 21:17:44     1.3
+++ due.util.sh  2004/10/24 18:59:45     1.4
@@ -156,3 +156,24 @@
     done
 }
 
+#   repeat a command
+function repeat () {
+    if [ $# -eq 0 ]; then
+        echo "Usage: repeat <number>|oo <command> [...]" 1>&2
+        return 1
+    fi
+    count="$1"
+    shift
+    if [ ".$count" = .oo ]; then
+        while true; do
+            eval "$@" || exit $?
+        done
+    else
+        local i=0
+        while [ $i -lt $count ]; do
+            eval "$@" || exit $?
+            i=$(($i + 1))
+        done
+    fi
+}
+

CVSTrac 2.0.1