#!/bin/bash

command_name=`basename $0`

if [ "$1" = "" ]; then
    echo "$command_name: Wrong option or parameter."
    echo "Get more information: \"$command_name --help\""
    exit -1
fi

if [ "$1" = "--help" ]; then
    echo "GNU DJPGG version of the UNIX CSH / TCSH internal \"repeat\" command."
    echo "Usage:   $command_name n command"
    echo "n:       number of repetitions,"
    echo "command: command to be executed n times."
    echo "Bugreports to: http://www.dipl-ing-kessler.de/email.htm"
    exit -1
fi

n=$1
counter=0
shift
command=$@

while [ $counter -lt $n ]; do
    counter=`expr $counter + 1`
    # echo "$command" >&2
    $command
done

exit 0
