it's just a moderately clever way to do a moderately ugly thing. When I saw the title of the post, I thought "uh, how on earth would you do that?"
I didn't stop and try to reason it out on my own, but then I clicked and saw the answer, and said "heh. cute." So there you go- enough people felt the same way I did, that the voting system moved this to the 4th link on the top page. /shrug. That's the internet for you!
How about a while true loop with cases in it on a state variable.
goto=42
while true ; do
case $goto in
1 )
code for label 1
goes here
break # finish
;;
42 )
code for label 42
goes here
goto=1
;;
esac
done
You don't have the syntactic sugar here, and there are some inconveniences, but think of the positives: this does not claim a new stack frame for each jump, let a lone a new stack frame holding a big string variable that holds most of the script source code.
I didn't stop and try to reason it out on my own, but then I clicked and saw the answer, and said "heh. cute." So there you go- enough people felt the same way I did, that the voting system moved this to the 4th link on the top page. /shrug. That's the internet for you!