explaingit

niieani/bash-oo-framework

5,619ShellAudience · developerComplexity · 2/5Setup · easy

TLDR

A modular framework that adds named function parameters, try-catch error handling, formatted stack traces, logging, unit testing, and basic object-oriented patterns to plain bash shell scripts.

Mindmap

mindmap
  root((Bash Infinity))
    What it does
      Named parameters
      Try-catch blocks
      Formatted stack traces
    Modules
      Logging with color
      Unit testing
      Type system
      Functional operations
    Design
      Modular and opt-in
      Copy single parts
      Import deduplication
    Requirements
      Bash 4 minimum
      Bash 4.3 for some modules
    Status
      Not for new projects
      v3.0 rewrite planned
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add named function parameters to bash scripts so arguments have meaningful names instead of numbered positions like $1 and $2.

USE CASE 2

Wrap risky bash commands in try-catch blocks so your deployment script handles errors gracefully instead of aborting.

USE CASE 3

Copy just the error-handling module into your own scripts to get formatted call-stack traces whenever a command fails.

USE CASE 4

Write unit tests for bash functions using the included testing library.

Tech stack

ShellBash

Getting it running

Difficulty · easy Time to first run · 30min

Requires bash 4, some modules need bash 4.3 or later for variable reference features, which macOS does not ship by default.

No license information is mentioned in the explanation.

In plain English

Bash Infinity is a framework and standard library for writing bash shell scripts in a more structured, readable style. Ordinary bash scripts rely on cryptic positional variables like $1 and $2, have no built-in error handling, and lack features that most other programming languages take for granted. Bash Infinity adds those features on top of bash without replacing it: you include the framework at the top of your script and pick only the parts you need. The most notable features are error handling and named function parameters. The error handling module catches failures and prints a formatted call stack showing exactly where a script went wrong, similar to how other languages display exceptions. It also provides try-catch blocks so code can respond to errors gracefully without stopping the script entirely. Named parameters let developers write function arguments with meaningful names rather than numbered positions, which makes scripts easier to read and maintain. Other included modules cover logging to the terminal with color output, a unit testing library, a type system for basic object-oriented patterns, and functional programming operations on data collections. An import statement handles loading library files, ensuring each file is loaded only once regardless of how many scripts reference it. The project is modular, so individual features such as named parameters or try-catch can be copied out and used on their own without pulling in the entire framework. The README notes that the framework lacks thorough test coverage and that the maintainer does not recommend starting large new projects based on it in its current state. A major rewrite is planned for version 3.0. For anyone who finds a specific part useful, the recommendation is to copy only those parts into their own code. The framework targets bash 4. Some modules require bash 4.3 or later for features like variable references.

Copy-paste prompts

Prompt 1
Using Bash Infinity, show me how to define a bash function with named parameters firstName and lastName and call it, replacing the usual $1 and $2 approach.
Prompt 2
I want to add try-catch error handling to my bash deployment script using Bash Infinity. Show me the import statement and a working try-catch example that catches a failed curl command.
Prompt 3
Copy only the Bash Infinity error-handling module into my project and wire it up so I get a formatted stack trace whenever any command in the script fails.
Open on GitHub → Explain another repo

← niieani on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.