: #	@(#)persist	1.1	try a command over upon error
# persist:
#	Repeats the command given as arguments PERSISTENCE times, if
#	necessary.  It exits 0 immediately upon successful execution
#	of the arguments, or 1 if it failed PERSISTENCE times.
# Author:  Larry Bamford, AO, SSD, COB, STS, ETC, 7/20/87

PERSISTENCE=3	# Number of times to retry a command that fails
NAPTIME=5	# time to sleep between retries

#case "$1" in
#-[1-9])
#	PERSISTENCE=`echo $1 | sed 's/^-//'`; shift;;
#esac

persistence=$PERSISTENCE
while test "$persistence" -gt 0
do
	eval $* && exit 0
	persistence=`expr $persistence - 1`
	if test $persistence -gt 0
	then
		sleep $NAPTIME
	fi
done
exit 1
