solution without using sed, grep and eval (yikes!);
does this suffice? i probably missed something obvious;
run with ./
case ${1-start} in
start)
# your script goes here...
x=100 $0 foo
;;
mid)
echo "This is not printed!"
x=101 $0 foo
;;
foo)
x=${x:-10}
echo x is $x
esac