Hacker News new | ask | show | jobs
Show HN: Toolbox – A framework for modular Bash scripts (m10k.eu)
3 points by m10k 1612 days ago
Everyday, I have to deal with Bash scripts and all the code duplication and unreadableness that comes with it. One day I found myself implementing an include function so that I could easily modularize my scripts, and it worked better than I had anticipated. That's how toolbox started.

At first, I wrote some simple modules for command line parsing and locking, but then I tried to see how far I could push the poor shell. I wrote modules for semaphores and "thread"-safe queues, and this is where things quickly started to escalate. To implement a distributed build system that automates packaging/signing/publishing of toolbox Debian packages, I wrote a module for message-based IPC that supports point-to-point and pub-sub communication. Performance was never a consideration, but it works really well without consuming excessive resources.

Some of the modules are arguably serious abuse of the shell, but I found that toolbox makes it possible to write Bash scripts that are readable, testable, and reliable. Shell isn't a terribly nice language, but it's great for integrating and automating things, so I thought others might find this useful, too.

(I am going to publish the build system as well, as soon as I am done writing the documentation.)

1 comments

That's awesome! Looks like you've been working on it for some time too: https://github.com/m10k/toolbox

You should put in a README on Github some how-to and explain what "modules" are available for inclusion and how they work!

Thanks! I didn't realize it's been almost a year already.

I decided very recently to publish this project on Github and write about it here, so documentation has not been a top priority. While writing about it, I realized that documentation will crucial though, so it is at the top of my list now (I was even pondering whether I should postpone posting on HN until the documentation is done).