niieani /bash-oo-framework
Bash Infinity is a modern standard library / framework / boilerplate for Bash
★ 5,621⑂ 243👁 132⑃ 41● 58▤ 3
+1
Daily
5,621
stars
243
forks
132
watchers
41
prs
58
issues
3
releases
README
Bash Infinity ============= Bash Infinity is a standard library and a boilerplate framework for writing tools using bash. It's modular and lightweight, while managing to implement some concepts from C, Java or JavaScript into bash. The Infinity Framework is also plug & play: include it at the beginning of your existing script to import any of the individual features such as error handling, and start using other features gradually. 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 ========== Some components are more sturdy than others, and as-it-stands the framework lacks good test coverage (we need your help!). Due to the above and relatively high code-complexity, we have decided that it will make the most sense to do a rewrite for the next major version 3.0 (see discussion in 45), taking the best parts of the framework, while re-using established tools from bash community. At this point, I would not recommend starting major projects based on the whole framework. Instead, copy and paste parts you need, ideally those you understand, if you found a particular feature useful. Compatibility ============= Not all of the modules work with earlier versions of bash, as I test with bash 4. However, it should be possible (and relatively easy) to port non-working parts to earlier versions. Quick-start =========== Single-file release and dynamic loading is not available for v2.0 yet. To load the framework locally, read on. Main modules ============ automatic error handling with exceptions and visual stack traces (util/exception) named parameters in functions (instead of $1, $2...) (util/namedParameters) passing arrays and maps as parameters (util/variable) try-catch implementation (util/tryCatch) throwing custom exceptions (util/exception) import keyword for clever sourcing of scripts à la require-js (oo-bootstrap) handy aliases for colors and powerline characters to increase readability in the output of your scripts (UI/Color) well-formatted, colorful logging to stderr or custom delegate functions (util/log) unit test library (util/test) standard library for the type system with plenty of useful functions (util/type) operational chains for functional programming in bash (util/type) type system for object-oriented scripting (util/class) All of the features are modular and it's easy to only import the ones you'd like to use, without importing the rest of the framework. For example, the named parameters or the try-catch modules are self-contained in individual files. Error handling with exceptions and throw ============================================== import util/exception One of the highlight features is error handling that should work out of the box. If the script generates
Top issues
#16Not running on bash <= 4.19 comments · 2016-02-15#62blanks are printed instead of stack trace in simple example8 comments · 2018-09-09#68Catch exception from Classes doesn't work7 comments · 2018-10-02#29Why are UI.Color members aliases?7 comments · 2017-12-07#66[bug?] `throw` is said to be 'undefined command' when `import` fail5 comments · 2018-10-01#48Complex example5 comments · 2018-06-18#43required packages5 comments · 2018-02-23#17Try catch causes docker conatiner crash with multiple sub shells.5 comments · 2016-04-20
Discussions
#108Project Status inquiry for 20251 comments · 2025-04-25#95[Discussion] Log API1 comments · 2021-06-17#89Welcome to bash-oo-framework Discussions!1 comments · 2020-12-09#90[Question] Is this project still alive?6 comments · 2020-12-08#91[RFC] 3.0: Scope, features and priorities16 comments · 2018-03-09#93How should call stacks be read?1 comments · 2018-01-16#92How do you work with variables outsite of the try catch but changing its value inside?4 comments · 2017-04-26