From 78de57aeb5810043572fe6c51e39d47b36b968e3 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Mon, 26 Jul 2021 12:17:24 -0700 Subject: [PATCH] lib: avoid duplicate inclusion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lib/log.bash | 11 ++++++++++- lib/utilities.bash | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/log.bash b/lib/log.bash index 6bc53a12..f9769d60 100644 --- a/lib/log.bash +++ b/lib/log.bash @@ -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_WARNING=2 diff --git a/lib/utilities.bash b/lib/utilities.bash index 575787d8..33e7aa8b 100644 --- a/lib/utilities.bash +++ b/lib/utilities.bash @@ -2,6 +2,13 @@ # # 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 ###########################################################################