Bash Infinity Framework
The aim of Bash Infinity is to maximize readability of bash scripts, minimize the amount of code repeat and create a central repository for well-written, and a well-tested standard library for bash.
Bash Infinity transforms the often obfuscated “bash syntax” to a cleaner, more modern syntax.
Disclaimer: Not all of the modules work with earlier versions of bash 3, as I test primarily with bash 4. However, it should be possible (and relatively easy) to port non-working parts to earlier versions.
- automatic error handling with exceptions and visual stack traces (
- named parameters in functions (instead of $1, $2…) (
- passing arrays and maps as parameters (
- try-catch implementation (
- throwing custom exceptions (
- import keyword for clever sourcing of scripts à la require-js (
- handy aliases for colors and powerline characters to increase readability in the output of your scripts (
- well-formatted, colorful logging to stderr or custom delegate functions (
- unit test library (
- standard library for the type system with plenty of useful functions (
- operational chains for functional programming in bash (
- type system for object-oriented scripting (
Most of the features are modular and it’s easy to simply use one of the features, e.g. the named parameters module is self-contained in one file.
For more information, please check out the GitHub repository for this project.
Functional and Object-oriented programming in bash?
As crazy as it may sound, the project implements a typing system and a class system. Believe it or not, but that definition in the picture above is in fact all valid Bash. There are other projects out there that aim to do the same, but they are not feature-complete, and the type definitions for most of them were ugly, at best. I wrote this as a part of an effort to rewrite SANEi to it’s next version, v2.0.
With Infinity Framework’s typing system, it becomes possible to write this kind of code in Bash.
Get the source
Feel free to fork and contribute.