aboutsummaryrefslogtreecommitdiffstats
path: root/examples/functions/repeat3
diff options
context:
space:
mode:
Diffstat (limited to 'examples/functions/repeat3')
-rw-r--r--examples/functions/repeat312
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/functions/repeat3 b/examples/functions/repeat3
new file mode 100644
index 0000000..65048bf
--- /dev/null
+++ b/examples/functions/repeat3
@@ -0,0 +1,12 @@
+# From psamuels@jake.niar.twsu.edu (Peter Samuelson)
+# posted to usenet, Message-ID: <6rtp8j$2a0$1@jake.niar.twsu.edu>
+
+repeat ()
+{
+ local i max; # note that you can use \$i in the command string
+ max=$1; shift;
+
+ i=1; while ((i <= max)); do
+ eval "$@"; ((i = i + 1));
+ done;
+}