From 778db5aaad4e175e1281a6442bcc41a483d1ac95 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Tue, 12 Oct 2021 10:27:46 -0700 Subject: [PATCH] lib/helpers: fix `_bash-it-describe()` --- lib/helpers.bash | 21 ++++++++++----------- test/lib/helpers.bats | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index a274c147..0a0d9e21 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -521,21 +521,20 @@ function _bash-it-describe() { file_type="$3" column_header="$4" - local f - local enabled + local f ff + local enabled enabled_file printf "%-20s%-10s%s\n" "$column_header" 'Enabled?' 'Description' - for f in "${BASH_IT}/$subdirectory/available"/*.bash; do + for f in "${BASH_IT?}/$subdirectory/available"/*.bash; do # Check for both the old format without the load priority, and the extended format with the priority - declare enabled_files enabled_file enabled_file="${f##*/}" - enabled_files=$(sort <(compgen -G "${BASH_IT}/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") | wc -l) - if [[ "$enabled_files" -gt 0 ]]; then - enabled='x' - else - enabled=' ' - fi - printf "%-20s%-10s%s\n" "$(basename "$f" | sed -e 's/\(.*\)\..*\.bash/\1/g')" " [$enabled]" "$(metafor "about-$file_type" < "$f")" + enabled= + for ff in "${BASH_IT}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${enabled_file}" \ + "${BASH_IT}/${subdirectory}/enabled/${enabled_file}" \ + "${BASH_IT}/${subdirectory}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${enabled_file}"; do + [[ -f "${ff}" ]] && enabled='x' + done + printf "%-20s %-10s %s\n" "${enabled_file%.$3*.bash}" "[${enabled:- }]" "$(metafor "about-$file_type" < "$f")" done printf '\n%s\n' "to enable $preposition $file_type, do:" printf '%s\n' "$ bash-it enable $file_type <$file_type name> [$file_type name]... -or- $ bash-it enable $file_type all" diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index 7f6664e0..3dec541c 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -583,5 +583,5 @@ function __migrate_all_components() { @test "helpers: describe the todo.txt-cli aliases without enabling them" { run _bash-it-aliases - assert_line "todo.txt-cli [ ] todo.txt-cli abbreviations" + assert_line "todo.txt-cli [ ] todo.txt-cli abbreviations" }