Bashing Away on My Keyboard

I've been coding in Bash for the last several days. Nothing makes me appreciate object-oriented programming quite like Bash does. Bash is not object-oriented.

Scoping is a nightmare in Bash. Everything is global unless you explicitly declare it local to a function. But functions can only return integers, so if you need a function to generate a string, you have to declare that string as a global variable. There is nothing like namespacing to be found. Classes, methods, and constructors? Surely, you jest.

So, why the heck am I programming in Bash? Well, I'm creating a suite of scripts to synchronize websites across multiple development environments (local, dev, stage, test, prod, and so forth) as well as any number of actual physical devices, with general failover support. The software is targeted specifically for sites which, for whatever reason, aren't easily manageable by git, Jenkins, and so forth. Though there's no reason you couldn't run the scripts via Jenkins.

I suppose, if I had it to do all over again, I'd probably write this project in Python. I enjoy writing in Python. I decided to go instead with pure Bash, because almost the entirety of what needs doing in this case is done using standard shell command tools like rsync, mysql, scp, and such. Wrapping these simple shell utilities in a language several steps removed seemed unaesthetic and lacking in parsimony.

I'm not sure I'll make the argument for aesthetics in the future, although the final work is definitely parsimonious. The core library weighs in at under 300 lines. It's amazing how much work it takes to reduce even simple software down to a few lines of code. And when you've finally done it, it looks for all the world as though you didn't do much at all.