niieani /bash-oo-framework

Bash Infinity is a modern standard library / framework / boilerplate for Bash

★ 5,621⑂ 243👁 132⑃ 41● 58▤ 3
下载:2.1bash-oo-framework-2.1 ↓2.12018-07-08
+1
日增长
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

Discussions

Latest release

2.1 2.1 2018-07-08

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON