#! /bin/sh

# usage: respawn FILE COUNT 

file=${1:?}
maxcount=${2:?}

count=0

if [ -f $file ]; then
    count=`cat $file`
    if test -n "$count" && test $count -ge $maxcount; then
       exit 1
    fi
fi

count=$(($count + 1))
echo "$count" > $file

exit 0

       
