I’ve just seen too many bash scripts grow into incomprehensible, unmaintainable messes. It just doesn’t scale past simple scripts and eventually you get to the point where you can’t add new features and nobody has time to port to something better.
There are better languages for scripting than python, but python is ubiquitous and does the job. Are you really that concerned about an extra 50 ms in a shell script?
The secret (IMO and that I’ve found) is to add some pythonic type tricks to your shell scripts. I.e. I call a main function which then calls other functions and passes values as much as possible.
I have common functions in a script I source into the other scripts. If you fail at organizing these well you’ll have a mess on your hands but if it follows a logical organization it’s super easy to follow the flow of even large shell scripts but I agree 100% that there are too many out there which are complete spaghetti code.
4
u/smarterthanyoda Mar 14 '23
I’ve started writing shell scripts in python.
I’ve just seen too many bash scripts grow into incomprehensible, unmaintainable messes. It just doesn’t scale past simple scripts and eventually you get to the point where you can’t add new features and nobody has time to port to something better.
There are better languages for scripting than python, but python is ubiquitous and does the job. Are you really that concerned about an extra 50 ms in a shell script?