2022-02-03

This commit is contained in:
Louis Seubert 2022-02-03 19:33:04 +01:00
commit db393215ce
Signed by: louis9902
GPG key ID: 4B9DB28F826553BD
55 changed files with 1907 additions and 0 deletions

View file

@ -0,0 +1,31 @@
# -*- mode: bash -*-
function abort() {
local status="${1:?"abort requires status"}"
local reason="${2:?"abort requires reason"}"
shift 2
# here we want the string as template
# shellcheck disable=SC2059
printf "error: ${reason}\n" "$@" >&2
exit "${status}"
}
function has_software() {
for software in "$@"; do
type "${software}" >/dev/null 2>&1 ||
abort 1 $"%s not found in path\n" "${software}"
done
}
function import() {
local name path file
for name in "$@"; do
local IFS=:; set -o noglob
for path in ${IMPORTPATH}; do
file="${path}/${name}"
[[ -e "${file}" && -r "${file}" ]] && {
source "${file}" && continue 2 || return 1
}
done
done
}