From 00f5f2a62ed2cd39787a255427b518bb4124d43e Mon Sep 17 00:00:00 2001 From: John D Pell Date: Mon, 18 Oct 2021 15:48:27 -0400 Subject: [PATCH] Use `_bash-it-egrep()` --- lib/helpers.bash | 4 ++-- lib/search.bash | 3 +-- lib/utilities.bash | 12 ++++++------ 3 files changed, 9 insertions(+), 10 deletions(-) mode change 100644 => 100755 lib/search.bash diff --git a/lib/helpers.bash b/lib/helpers.bash index 94df885d..f11df4be 100755 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -711,8 +711,8 @@ _enable-thing () # Load the priority from the file if it present there declare local_file_priority use_load_priority - local_file_priority=$(grep -E "^# BASH_IT_LOAD_PRIORITY:" "${BASH_IT}/$subdirectory/available/$to_enable" | awk -F': ' '{ print $2 }') - use_load_priority=${local_file_priority:-$load_priority} + local_file_priority="$(_bash-it-egrep "^# BASH_IT_LOAD_PRIORITY:" "${BASH_IT}/$subdirectory/available/$to_enable" | awk -F': ' '{ print $2 }')" + use_load_priority="${local_file_priority:-$load_priority}" ln -s ../$subdirectory/available/$to_enable "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}" fi diff --git a/lib/search.bash b/lib/search.bash old mode 100644 new mode 100755 index 58f98904..8bd95b8e --- a/lib/search.bash +++ b/lib/search.bash @@ -57,7 +57,6 @@ _bash-it-search() { local component export BASH_IT_SEARCH_USE_COLOR=true - export BASH_IT_GREP=${BASH_IT_GREP:-$(which egrep)} declare -a BASH_IT_COMPONENTS=(aliases plugins completions) if [[ -z "$*" ]] ; then @@ -168,7 +167,7 @@ ${echo_underline_yellow}SUMMARY${echo_normal} _bash-it-is-partial-match() { local component="$1" local term="$2" - _bash-it-component-help "${component}" | $(_bash-it-grep) -E -i -q -- "${term}" + _bash-it-component-help "${component}" | _bash-it-egrep -i -q -- "${term}" } _bash-it-component-term-matches-negation() { diff --git a/lib/utilities.bash b/lib/utilities.bash index 1f249b98..575787d8 100644 --- a/lib/utilities.bash +++ b/lib/utilities.bash @@ -82,7 +82,7 @@ function _bash-it-component-help() { file="$(_bash-it-component-cache-file "${component}")" if [[ ! -s "${file}" || -z "$(find "${file}" -mmin -300)" ]]; then func="_bash-it-${component}" - "${func}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E ' \[' >| "${file}" + "${func}" | _bash-it-egrep ' \[' >| "${file}" fi cat "${file}" } @@ -130,17 +130,17 @@ function _bash-it-component-list-matching() { local component="$1" shift local term="$1" - _bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -- "${term}" | awk '{print $1}' | sort -u + _bash-it-component-help "${component}" | _bash-it-egrep -- "${term}" | awk '{print $1}' | sort -u } function _bash-it-component-list-enabled() { local IFS=$'\n' component="$1" - _bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E '\[x\]' | awk '{print $1}' | sort -u + _bash-it-component-help "${component}" | _bash-it-egrep '\[x\]' | awk '{print $1}' | sort -u } function _bash-it-component-list-disabled() { local IFS=$'\n' component="$1" - _bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -v '\[x\]' | awk '{print $1}' | sort -u + _bash-it-component-help "${component}" | _bash-it-egrep -v '\[x\]' | awk '{print $1}' | sort -u } # Checks if a given item is enabled for a particular component/file-type. @@ -154,7 +154,7 @@ function _bash-it-component-list-disabled() { function _bash-it-component-item-is-enabled() { local component="$1" local item="$2" - _bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E '\[x\]' | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -q -- "^${item}\s" + _bash-it-component-help "${component}" | _bash-it-egrep '\[x\]' | _bash-it-egrep -q -- "^${item}\s" } # Checks if a given item is disabled for a particular component/file-type. @@ -168,5 +168,5 @@ function _bash-it-component-item-is-enabled() { function _bash-it-component-item-is-disabled() { local component="$1" local item="$2" - _bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -v '\[x\]' | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -q -- "^${item}\s" + _bash-it-component-help "${component}" | _bash-it-egrep -v '\[x\]' | _bash-it-egrep -q -- "^${item}\s" }