Skip to content

init

Initialize libbash.

Note

This library needs to be loaded before all other libraries so that the LIBBASH_DIR variable can be loaded.

Note

This library automatically loads the helpers library.

Variables:
Name Type Description
LIBBASH_DIR Enviromental The absolute path for libbash

lb_lsf

List all libbash functions.

Parameters:
Name Type Description Default
None - - -
Examples:
#!/usr/bin/env bash

# shellcheck source=/dev/null
source ../init

function main() {
  lb_lsf
}

main "${@}"
Show source code in init
#!/usr/bin/env bash

if (( BASH_VERSINFO[0] < 4 )); then
  printf "Bash Lib requires bash v4 or greater\n"
  printf "Current Bash Version: %s\n" "${BASH_VERSION}"
  exit 1
fi

# Shell Otions
set -euo pipefail

# Get the relative path to the repo root
# shellcheck disable=SC2034
LIBBASH_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# shellcheck source=/dev/null
source "${LIBBASH_DIR}/helpers"

# Filter functions and re export only bash-lib functions to subshells
eval "$(declare -F | sed -e 's/-f /-fx /' | grep 'x lb_')"

function lb_lsf(){
  declare -F | sed -e 's/-f /-fx /' | grep 'x lb_'
}