Alternatives to goto in bash

As we know:

  1. There is no goto statement support in bash.

  2. 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.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *