From c3eaa606de4e63cf75d5f1cce60bec2df7edd575 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 23 Oct 2021 22:31:32 -0700 Subject: [PATCH] lib/utilities: fix `_bash-it-component-help()` for long component names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alsö, minor tweak to `_bash-it-array-contains-element()` for clarity. This fixes Bash-It/bash-it#1978. --- lib/utilities.bash | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/utilities.bash b/lib/utilities.bash index 42e785b9..79cb8073 100644 --- a/lib/utilities.bash +++ b/lib/utilities.bash @@ -47,9 +47,10 @@ function _bash-it-get-component-type-from-path() { # # function _bash-it-array-contains-element() { - local e - for e in "${@:2}"; do - [[ "$e" == "$1" ]] && return 0 + local e element="${1?}" + shift + for e in "$@"; do + [[ "$e" == "${element}" ]] && return 0 done return 1 } @@ -82,7 +83,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-egrep ' \[' >| "${file}" + "${func}" | _bash-it-egrep '\[[x ]\]' >| "${file}" fi cat "${file}" }