lib/utilities: fix `_bash-it-component-help()` for long component names

Alsö, minor tweak to `_bash-it-array-contains-element()` for clarity.

This fixes Bash-It/bash-it#1978.
pull/1999/head
John D Pell 2021-10-23 22:31:32 -07:00
parent e3bd30f98d
commit c3eaa606de
1 changed files with 5 additions and 4 deletions

View File

@ -47,9 +47,10 @@ function _bash-it-get-component-type-from-path() {
# #
# #
function _bash-it-array-contains-element() { function _bash-it-array-contains-element() {
local e local e element="${1?}"
for e in "${@:2}"; do shift
[[ "$e" == "$1" ]] && return 0 for e in "$@"; do
[[ "$e" == "${element}" ]] && return 0
done done
return 1 return 1
} }
@ -82,7 +83,7 @@ function _bash-it-component-help() {
file="$(_bash-it-component-cache-file "${component}")" file="$(_bash-it-component-cache-file "${component}")"
if [[ ! -s "${file}" || -z "$(find "${file}" -mmin -300)" ]]; then if [[ ! -s "${file}" || -z "$(find "${file}" -mmin -300)" ]]; then
func="_bash-it-${component}" func="_bash-it-${component}"
"${func}" | _bash-it-egrep ' \[' >| "${file}" "${func}" | _bash-it-egrep '\[[x ]\]' >| "${file}"
fi fi
cat "${file}" cat "${file}"
} }