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?

asked Mar 31, 2014 by Eric Z Ma (44,280 points)

1 Answer

Best answer

Robert Copeland gave an interesting hacking to this problem:

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.

answered Mar 31, 2014 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost