bashly icon indicating copy to clipboard operation
bashly copied to clipboard

Bashly is a collection of solutions to common problems that arise when writing scripts in the bash shell. You can call it a library. Just keep in mind that reusable bash code is hard, so it might not...

bashly

This project, bashly, is yet another attempt of a library of reusable bash functions. Though its development is driven by the following core principles:

  • Encapsulate all state within the functions (no global variables)
  • Avoid ''eval'' at all costs. It is really hard to read scripts that (ab)use eval, and even more difficult to maintain. There are also security risks associated to the use of eval.
  • Avoid external commands, bashly attempts to be standalone. The only commands that are going to be used are: od (it's POSIX, and to overcome the binary stream handling of bash). This should make it very portable across systems where bash is available.
  • Lots of tests. Code should be written with testability in mind.
  • Follow best practices for bash programming.
  • Make it easy to create stand-alone scripts that are linked to the bashly modules, but also make it easy to update linked scripts.

The modules (or libraries) reside in the lib/ hierarchy. They have the bashly extension, to easily identify them as libraries. Each library should have its own battery of tests under the test/ hierarchy. Also, each library should have its own documentation under docs/lib.

You will find sample scripts based on bashly under the src/ directory, with their "linked" forms under bin/

Feed-back in the form of issues is greatly appreciated.