I’ve come across a number of programs in the past and thought to myself,
“Why didn’t they script this, it would be so much easier.”
After thinking about it for a while it all makes sense now. It seems that I had the shell script bug, everything must be done in the shell! In reality while the shell is great and all, it is not without its flaws. There are somethings the shell is great at and should be used for, then there others it shouldn’t.
Don’t get me wrong, I like to script as much as the next guy, but sometimes I think people get lost in its simplicity. Some people use it for everything without fail. Perhaps this is because they don’t know otherwise, or maybe because they too have the shell script bug.
There are many reasons to use the shell and I’m not against using it by any means. This is simply a list of when it may not be suitable to whip out the shell and start scripting. If there is any I missed, please add them in the comments and they may eventually make it into a revised post. I’ll do the same if I come up with any more. Onto the list!
Distribution / Portability – Ever try to distribute a script? Well, most of the time its not a problem, but sometimes you’ll get bit in the ass. Not all systems are created equal. Some have missing packages, or something doesn’t work the EXACT same way.
Simplicity – Sometimes bash is elegant. Well, it depends on your definition I guess. Some argue that scripting is simple, where as others that have to support or maintain it will be ready to cut you. I know I’m sharpening my shanks right now for some revenge. Seriously though, choose a language that makes it easy to K.I.S.S (keep it simple, stupid.)
Performance – Lets kick in the after burners. This is one I don’t have much experience in although I should probably look into it. The shell is sort of like a glider, it gets the jobs done, but I wouldn’t want to race it against a jet or anything. If you’re considering scripting, just time the process to make sure it meets your performance needs. Most of the time, if it is for you, you’ll be fine right? I mean you’ve got all of the time in the world and can wait overnight if you have to. I’d rather not, but have been known to wait on a slow script out of laziness.
Maintenance – Nightmare code. Dependency Hell. Some may have seen the t-shirt or heard the phrase,
“Programming is like sex; one mistake, and you’ll support it forever”
Yea scripting this is sort of like that, except you can always abandon and upgrade your scripts :)
Security – Keep it secure, there are many issues with security in shell scripts. We wont get into them now but if you wear a tinfoil hat when using a computer, you may not want to rely on shell scripts to do your top secret stuff.