Skip to content

L_lib.sh

my labrador dog

Labrador Bash library. Collection of functions and libraries that I deem useful for working with Bash.

Installation

The library is one file. Download the latest release from GitHub and put in your PATH:

mkdir -vp ~/.local/bin/
curl -o ~/.local/bin/L_lib.sh https://raw.githubusercontent.com/Kamilcuk/L_lib/refs/heads/v1/bin/L_lib.sh
export PATH=~/.local/bin:$PATH

You can use the library in scripts with:

. L_lib.sh -s

Unless -n, sourcing the library will enable extglob and patsub_replacement and, if set -e is set, register a ERR trap that will print a nice traceback on unhandled error.

You can test the library ad-hoc:

bash <(curl -sS https://raw.githubusercontent.com/Kamilcuk/L_lib/refs/heads/v1/bin/L_lib.sh) L_setx L_log 'Hello world'

Features

Below is some list with some of the library features. The library contains much more.

Talk to me

Kindly feel free to have conversations and ask questions on GitHub discussion.

Report bugs using GitHub issue.

Conventions

  • L_* prefix for public symbols.
  • _L_* prefix for private symbols, including local variables in functions taking a name-reference.
  • Upper case used for global scope read-only variables.
  • Lower case used for functions and user mutable variables
  • Snake case for everything.
  • The option -v <var> is used to store the result in a variable instead of printing it.
    • This follows the convention of printf -v <var>.
    • Without the -v option, the function outputs the elements on lines to standard output.
    • Associated function with _v suffix store the result in a hardcoded scratch variable L_v.
  • return 2 on usage error, return 124 on timeout

License

LGPL