Skip to content

all

A library to import all libraries.

Examples:
#!/usr/bin/env bash

# shellcheck source=/dev/null
source ../init
source "${LIBBASH_DIR}/all"

function main() {
  s=$(lb_repo_root)
  printf "lb_repo_root: %s\n" "${s}"
}

main "${@}"
Show source code in all
#!/usr/bin/env bash
: "${LIBBASH_DIR:?LIBBASH_DIR must be set. Please source libbash/init before other libraries.}"

libs=()
# Get an array of all libraries
for f in "${LIBBASH_DIR}"/*; do
  [[ -f "${f}" ]] && \
  [[ "${f}" != *"init" ]] && \
  [[ "${f}" != *"all" ]] && \
  [[ "${f}" != *"helpers" ]] && \
  [[ "${f}" != *"logging" ]] && \
  [[ $(\head "${f}" -n1) == "#!/usr/bin/env bash" ]] && \
    libs+=("${f}")
done

# Load all libraries
for lib in "${libs[@]}"; do
  if [[ -r "${lib}" ]] && [[ -f "${lib}" ]]; then
    # shellcheck source=/dev/null
    source "${lib}"
  fi
done