gobash documentation

gobash is a set of bash functions that improve programming experience in bash (by providing collections, languages features, APIs, testing package, command line flag parsing, etc.) without modifying the shell interpreter(s). It works with any bash version (on Linux and Mac). Parts of the API match those in Go.

gobash is publicly available on GitHub under the BSD-3-Clause license. The dependencies needed to run gobash are listed on that GitHub page.

Here is a quick example that uses gobash (check later sections for more):

#!/bin/bash

# Import the library.
source /dev/stdin <<< "$(curl https://raw.githubusercontent.com/EngineeringSoftware/gobash/master/hsabog 2>/dev/null)"

# Create a communication channel.
ch=$(Chan)
# Send a message (blocking call) in a sub process.
( lst=$(List 2 3 5); $ch send "$lst" ) &

# Receive the message (blocking call) in the main process.
lst=$($ch recv)

$lst to_string
# Output:
# [
#   "2",
#   "3",
#   "5"
# ]

If you love learning by example, take a look at the examples page. A quick demo of the very basic concepts using a toy example is available here.

Indices and tables