From 550f8088843e3de2db4fdceb241baea90db5c4ff Mon Sep 17 00:00:00 2001 From: John D Pell Date: Mon, 3 Jan 2022 16:59:50 -0800 Subject: [PATCH] lib/helpers: fix `_bash-it-describe()` Use `_bash-it-component-item-is-enabled()` Fix SC2295 --- lib/helpers.bash | 22 +++++++++------------- test/lib/helpers.bats | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 9f9bc797..ee327845 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -689,14 +689,10 @@ _bash-it-determine-component-status-from-path() { # Check for both the old format without the load priority, and the extended format with the priority local enabled_files enabled_file enabled_file="${f##*/}" - enabled_file="${enabled_file%.*.bash}" - 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 + enabled_file="${enabled_file%."${file_type}"*.bash}" + enabled= + _bash-it-component-item-is-enabled "${file_type}" "${enabled_file}" && enabled='x' + return 0 } function _bash-it-describe() { @@ -713,11 +709,11 @@ function _bash-it-describe() { column_header="$4" local f - local enabled - printf "%-20s%-10s%s\n" "$column_header" 'Enabled?' 'Description' - for f in "${BASH_IT}/$subdirectory/available"/*.bash; do + local enabled enabled_file + printf "%-20s %-10s %s\n" "$column_header" 'Enabled?' 'Description' + for f in "${BASH_IT?}/$subdirectory/available"/*.*.bash; do _bash-it-determine-component-status-from-path "$f" - printf "%-20s%-10s%s\n" "$enabled_file" " [$enabled]" "$(metafor "about-$file_type" < "$f")" + printf "%-20s %-10s %s\n" "$enabled_file" "[${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" @@ -1004,7 +1000,7 @@ function _help-plugins() { rm "$grouplist" 2> /dev/null } -_help-profile() { +function _help-profile() { _about 'help message for profile command' _group 'lib' diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index e8275e9d..6e145eec 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -732,5 +732,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" }