From e3bd30f98d435bb1d04fb144785df3922a7ef355 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 23 Oct 2021 22:29:09 -0700 Subject: [PATCH] lib/utilities: autonomize `_bash-it-component-item-is-enabled()` Make `_bash-it-component-item-is-enabled()` operate *without* using `_bash-it-component-help()`...so it's now *much* faster. --- lib/utilities.bash | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/utilities.bash b/lib/utilities.bash index 575787d8..42e785b9 100644 --- a/lib/utilities.bash +++ b/lib/utilities.bash @@ -144,7 +144,6 @@ function _bash-it-component-list-disabled() { } # Checks if a given item is enabled for a particular component/file-type. -# Uses the component cache if available. # # Returns: # 0 if an item of the component is enabled, 1 otherwise. @@ -152,13 +151,17 @@ function _bash-it-component-list-disabled() { # Examples: # _bash-it-component-item-is-enabled alias git && echo "git alias is enabled" function _bash-it-component-item-is-enabled() { - local component="$1" - local item="$2" - _bash-it-component-help "${component}" | _bash-it-egrep '\[x\]' | _bash-it-egrep -q -- "^${item}\s" + local component="$1" item="$2" + local each_file + + for each_file in "${BASH_IT}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item}.${component}"*."bash" \ + "${BASH_IT}/${component}"*/"enabled/${item}.${component}"*."bash" \ + "${BASH_IT}/${component}"*/"enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item}.${component}"*."bash"; do + [[ -f "${each_file}" ]] && return + done } # Checks if a given item is disabled for a particular component/file-type. -# Uses the component cache if available. # # Returns: # 0 if an item of the component is enabled, 1 otherwise. @@ -166,7 +169,5 @@ function _bash-it-component-item-is-enabled() { # Examples: # _bash-it-component-item-is-disabled alias git && echo "git aliases are disabled" function _bash-it-component-item-is-disabled() { - local component="$1" - local item="$2" - _bash-it-component-help "${component}" | _bash-it-egrep -v '\[x\]' | _bash-it-egrep -q -- "^${item}\s" + ! _bash-it-component-item-is-enabled "$@" }