Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
do.times
error() {
echo "$1" >&2
return 1
}
is_integer() {
case "$1" in
''|*[!0-9]*)
return 1
;;
*)
return 0
;;
esac
}
do.times() {
local times=$1
shift
if is_integer $times;then
for i in $(seq 1 $times); do
eval $@
done
else
error "Positive integer expected as first argument"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment