gobash documentation¶
gobash, a self-proclaimed standard bash library, is a set of bash functions that improve programming experience in bash (by providing collections, structs, methods, 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/main/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.
- Motivation
- Design
- Get Started
- Language Features
- Collections
- Inter-process Communication
- Interactive Mode
- Testing Package
- Command Line Flags
- Next
- API
- testing/bunit.sh
- testing/testt.sh
- testing/bunit_result.sh
- external/git/github.sh
- net/http.sh
- net/response.sh
- net/handler.sh
- net/request.sh
- sync/chan.sh
- sync/wait_group.sh
- sync/atomic_int.sh
- sync/mutex.sh
- lang/result.sh
- lang/log.sh
- lang/bool.sh
- lang/x.sh
- lang/unsafe.sh
- lang/assert.sh
- lang/sys.sh
- lang/pipe.sh
- lang/runtime.sh
- lang/os.sh
- lang/jqmem.sh
- lang/int.sh
- lang/core.sh
- lang/make.sh
- lang/bash.sh
- database/sql.sh
- ui/ui.sh
- ui/textui.sh
- ui/whiptail.sh
- util/rand.sh
- util/user.sh
- util/complex.sh
- util/flags.sh
- util/list.sh
- util/fileinfo.sh
- util/os.sh
- util/binary.sh
- util/math.sh
- util/regexp.sh
- util/set.sh
- util/time.sh
- util/filepath.sh
- util/map.sh
- util/char.sh
- util/strings.sh
- util/file.sh
- tools/bdoc.sh
- tools/blint.sh
- container/ring.sh
- container/list.sh