Set start point in script

Does anyone know of a way to set up some sort of marker in a shell script, from which the script can be restarted..

e.g.

MARKER1
check env variable MAX_RETRY
if var not set then
while true
do
check var
if set go to MARKER1
else sleep
done
fi

ANy ideas?

what are you trying to do? ... btw, your test as i understand it will never hold true as you're checking for an environment variable that should already be set BEFORE the script gets to the test ... if not already set, who's going to set it?

I wouldnt necessarily do it this way but you could set a flag within the shell (preferably at the top of the script) using sed. Basically, create a pattern that is unique so that you can use a simple sed statement to set a shell variable before the shell exits. If the shell is restarted it could perform work based upon the setting of this variable. To make this work you would need to create a function that is a single point of exit within the script. Anything goes wrong you call the function, runs the sed, and exits gracefully.