Goto in Bash (2012)

If you’re a nerdy old-timer like me, you might remember hacking in the BASIC computer language during your grade school days. One of the features of this mostly hated language was that each statement required a line number. Surprisingly, you could actually use line numbers to run your program from any random point, similar to a “bash goto” command. Although this feature is not available in modern bash scripting, I have developed a workaround for a specific script I use at work. By running sed on the script and then evaling it, I am able to continue the script from the point of failure rather than manually copying and pasting commands. It’s a bit cringe-worthy, but it gets the job done. My goal of making bash look like assembly language is getting closer to reality.

https://bobcopeland.com/blog/2012/10/goto-in-bash/

To top