Alternatives to goto in bash
Posted on In QAAs we know:
There is no
goto
statement support in bash.goto
is useful for certain situations, especially for debugging.
So, is there any alternative mechanisms to goto in bash?
Robert Copeland gave an interesting hacking to this problem: http://bobcopeland.com/blog/2012/10/goto-in-bash/
The idea is like the self-modifying code. But the difference is to generate a piece of the script and eval
(run) it. This is not exactly the goto
statement, but achieve the very close results.