One of the most powerful aspects of popular high-level languages is the existence of a comprehensive standard library. Unfortunately, the most popular Linux shell, bash, lacks a full-featured library bundled with it. A number of people have written libraries to compensate for this lack, which can make your life infinitely easier if you need to write complex bash scripts. Here are links to all the bash/shell-scripting libraries and collections I’m aware of:
- Marco’s Bash Functions Library (mbfl)
- Bash Shell Function Library (bsfl)
- Bashinator: Bash Shell Script Framework (by our own wschlich)
- shesfw: shell script framework tool
- Wicked Cool Shell Scripts library (from the book)
- UNIX Power Tools library (from the book)
- Portable Shell Programming (from the book)
- Learning the bash shell (from the book)
- Bash Cookbook (from the book)
- Classic Shell Scripting (from the book)
- shunit2: A unit-test framework
- log4sh: A flexible logging framework
- libbash: Enables creation of dynamic-like shared libraries
- bashworks: Framework depending on bash-4 or newer
- bfw: Bash FrameWork (Harvard Neuroinformatics)
- rerun: Turns loose shell scripts into modular automation
It was a real pain to come up with this whole list, so hopefully it’s useful to some of you. In future posts, I’m thinking of reviewing these libraries in more depth and comparing them to equivalent functionality in Python, my other language of choice. My goal is not to have functionality re-implemented in shell script to replace basic tools like head/tail, but instead to discover or create (if necessary) a library using the full suite of standard UNIX tools to provide a fun and convenient experience for shell scripters.
Update (2013/07/08): Added rerun.
Update: Fixed a couple of broken links (bashworks and Portable Shell).
13 thoughts on “Bash shell-scripting libraries”
I’m maintaining libui-sh, I UI-abstraction framework for bash (supporting both cli and ncurses through dialog)
A full featured standard library could probably come out of portage.
Although its not a bash framework, I have created a modular bash script called monkey tail which can merge and unmerge code into itself.
Dude would be nice to have a comparison among those! 😀
Pretty awsome list! Thanks for sharing it! +1 on some description/comparison of the libraries.
Nice list you made, some I’m familiar with, others are new to me. I’m the person messing around with BSFL. This is still a work in progress and may not serve all needs, but I hope someone may find a use for it.
BSFL is not for advanced stuff, but provides basic functionality to make your shell scripts more human friendly regarding output (status messages, logging, etc) but it is not limited to this.
If people have any ideas/suggestions about what they certainly would want from a bash library, please tell me.
Friend of mine did this:
mainly object oriented string operations, java-python style
Thanks for this list! I’m a big fan of using shell functions myself, that’s why I wrote app-shells/prll. It’s meant to parallelize shell functions.
Another me too for the comparison.
Having programmed bash for 20 years now, I _do_ believe that if your bash code becomes too complex and large, its a sign that you should rewrite into another language. Unless bash is written particularly cleanly (“set -e”, only “local” variables, clean STDOUT/STDERR handling, …) it is hard to read and maintain large bash scripts. And they can be slow besides.
In that way it’s similar to make: if your Makefile becomes too complicated, it’s a sign you are trying to be too complex for the language.
While I generally do agree that overly complex apps should not be written in bash, there are times when this may not be so easily avoidable. Other times things only seem complex. Having library that makes scripting easier is definitely a good thing.
Consider adding BLIB -> http://bit.ly/i7tZWH to your list.
Comments are closed.