From 5ff873e0582dc40c72911cff9f86d1cbb030256b Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Fri, 15 Sep 2017 08:10:16 +0200 Subject: [PATCH] Fixed "bash-it help aliases" cases, more to come... --- lib/helpers.bash | 9 ++++++++- test/lib/helpers.bats | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 16b31946..0c292621 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -454,11 +454,18 @@ _help-aliases() cat "${BASH_IT}/aliases/$alias_path" | metafor alias | sed "s/$/'/" else typeset f + shopt -s nullglob + for f in "${BASH_IT}/aliases/enabled/"* do _help-list-aliases $f done - _help-list-aliases "${BASH_IT}/aliases/custom.aliases.bash" + + shopt -u nullglob + + if [ -e "${BASH_IT}/aliases/custom.aliases.bash" ]; then + _help-list-aliases "${BASH_IT}/aliases/custom.aliases.bash" + fi fi } diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index bf1865fa..9a98f8df 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -30,6 +30,17 @@ function local_setup { # TODO Create global __get_base_name function # TODO Create global __get_enabled_name function +@test "helpers: bash-it help aliases ag" { + run bash-it help alias "ag" + assert_line "0" "ag='ag --smart-case --pager=\"less -MIRFX'" +} + +@test "helpers: bash-it help aliases without any aliases enabled" { + run bash-it help alias + echo "${lines[@]}" + assert_line "0" "" +} + @test "helpers: enable the todo.txt-cli aliases through the bash-it function" { run bash-it enable alias "todo.txt-cli" assert_line "0" 'todo.txt-cli enabled with priority 150.'