You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
640 B
Bash
37 lines
640 B
Bash
LOADED_LIBS=
|
|
|
|
include() {
|
|
local file
|
|
for file in "${@}"; do
|
|
if [ -f "${XDG_DATA_HOME}/buddy/lib/${file}.sh" ]; then
|
|
# shellcheck disable=SC1090
|
|
. "${XDG_DATA_HOME}/buddy/lib/${file}.sh"
|
|
else
|
|
>&2 echo "include unknown: ${file}"
|
|
exit 1
|
|
fi
|
|
done
|
|
}
|
|
|
|
require() {
|
|
local file
|
|
local previous
|
|
for file in "${@}"; do
|
|
echo "$LOADED_LIBS" | while read -r previous; do
|
|
if [ -z "${previous}" ]; then
|
|
continue
|
|
elif [ "${previous}" = "${file}" ]; then
|
|
continue 2
|
|
fi
|
|
done
|
|
|
|
if [ -z "${LOADED_LIBS}" ]; then
|
|
LOADED_LIBS=${file}
|
|
else
|
|
LOADED_LIBS="${LOADED_LIBS}\n${file}"
|
|
fi
|
|
|
|
include "${file}"
|
|
done
|
|
}
|