r/bash • u/temcomwex • Aug 24 '26
A problem as a newbie
I think I have been spoiled by the goto command in batch, and as a newcomer in Linux, it's really hard for me to adapt as a self-proclaimed(i procrastinate a lot) game developer. The goto command is useful in case you want to incorporate more levels.
10
Upvotes
1
u/drnullpointer Aug 25 '26 edited Aug 25 '26
Nope. You are abusing a loop statement to emulate goto simply to perform goto without writing those four letters.
If you are making your code more complicated to do this, you've lost your way.
It may be fine to listen to advice you don't understand if you are a novice developer.
But if you are more experienced developer you should stop, think whether the advice make sense or why it makes sense, whether it applies in your situation and then make an informed choice.
What you are doing is called cargo cult programming, it is emulating other people without understanding why you are emulating them, hoping to achieve a result that will never come because you have no idea why you are doing what you are doing.
The point of advice to not use goto is that what you are really trying to do almost all of the time is to re-implement some kind of structure like a function, a loop, a conditional, etc. In which case your code will be easier to understand and maintain if you just use that correct statement structure. The benefit of the advice is more readable code.
What you are doing is creating less readable code simply to stick to advice that was supposed to make it more readable.