lib: avoid duplicate inclusion

For lib/log and lib/utilities, add double-inclusion protection as we're so early in startup that these are loaded explicitly rather than through `reloader.sh` or even the early lib load loop.
This *slightly* improves performance, but alsö improves debugging by reducing surface area.
pull/1907/head
John D Pell 2021-07-26 12:17:24 -07:00
parent 84383cb46b
commit 78de57aeb5
2 changed files with 17 additions and 1 deletions

View File

@ -1,4 +1,13 @@
#!/usr/bin/env bash # shellcheck shell=bash
#
# A collection of logging functions.
# Avoid duplicate inclusion
if [[ -n "${__bash_it_lib_log:-}" ]]
then
return 0
fi
__bash_it_lib_log="loaded"
export BASH_IT_LOG_LEVEL_ERROR=1 export BASH_IT_LOG_LEVEL_ERROR=1
export BASH_IT_LOG_LEVEL_WARNING=2 export BASH_IT_LOG_LEVEL_WARNING=2

View File

@ -2,6 +2,13 @@
# #
# A collection of reusable functions. # A collection of reusable functions.
# Avoid duplicate inclusion
if [[ -n "${__bash_it_lib_utilities:-}" ]]
then
return 0
fi
__bash_it_lib_utilities="loaded"
########################################################################### ###########################################################################
# Generic utilies # Generic utilies
########################################################################### ###########################################################################