Giter VIP home page Giter VIP logo

gobash's Introduction

gobash

test (bash 3) test (bash 4) test (bash 5) test (mac) lint

gobash is a set of 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 are matching those in Go.

For more information about gobash, see the main documentation page: http://gobash.org.

API documentation is available here.

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.

Key Features

We focused on a design that enables the following key features (discussed in more detail at gobash.org):

  • Programming language features - gobash enables (via functions and files) defining structs and methods and instantiating "objects", e.g., example
  • Arguments and return values - gobash supports passing "objects" as arguments to functions and returning them as "out" arguments, e.g., example
  • Collections - gobash (using structs) provides a flexible collections: Lists and Maps (thus avoiding built-in structures when they are not sufficiently flexible or they are not available in old versions), e.g., example
  • Command line flag parsing - gobash introduces a set of functions for parsing command line flags (similar to those in other programming languages), e.g., example
  • Testing - gobash comes with a testing package, e.g., example
  • API - gobash provides a set of functions to support common tasks and abstractions, such as strings, Mutex, Chan, e.g., example

A Quick Example

#!/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"
# ]

Dependencies

gobash uses several bash builtins, GNU coreutils, and binaries widely available on Unix. Although the repository keep changing, the list probably includes jq, sed, grep, awk, date.

Versioning

gobash was tested on Linux with the following bash versions:

gobash bash 3 bash 4 bash 5
1.0.1-dev 3.2.57 4.4.18 5.0.17

We also test on Mac. Please see the CI runs for details and up-to-date information.

(gobash versions prior to 1 were internal releases. Once we stabilize API or someone starts using the library, we will make public releases.)

Acknowledgments

I would like to thank Ahmet Celik, Owolabi Legunsen, Darko Marinov, Pengyu Nie, and Aditya Thimmaiah for years of joint fun with bash. Also, I would like to thank Aleksandar Milicevic for his feedback on this project.

License

BSD-3-Clause license.

Contact

Feel free to get in touch if you have any comments: Milos Gligoric <[email protected]>.

gobash's People

Contributors

gliga avatar ivangrigorik avatar owolabileg avatar pengyunie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gobash's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.