Skip to content

Commit

Permalink
lib/helpers: handle unbound parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelicWizard committed Feb 10, 2022
1 parent 334f072 commit 3efc183
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ source "${BASH_IT}/lib/log.bash"
source "${BASH_IT?}/lib/utilities.bash"
# shellcheck source-path=SCRIPTDIR/lib
source "${BASH_IT?}/lib/helpers.bash"
# shellcheck source-path=SCRIPTDIR/themes
source "${BASH_IT?}/themes/colors.theme.bash"
# shellcheck source-path=SCRIPTDIR/lib
source "${BASH_IT?}/lib/colors.bash"

if [[ -n $interactive && -z "${silent}" ]]; then
for type in "aliases" "plugins" "completion"; do
Expand Down
21 changes: 12 additions & 9 deletions lib/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ _bash-it-profile-load-parse-profile() {
break
fi
# Do not actually modify config on dry run
[[ -z $2 ]] || continue
[[ -z ${2:-} ]] || continue
# Actually enable the component
$enable_func "$component"
done < "$1"
Expand Down Expand Up @@ -704,7 +704,9 @@ function _on-disable-callback() {
_group 'lib'

local callback="${1}_on_disable"
_command_exists "$callback" && "$callback"
if _command_exists "$callback"; then
"$callback"
fi
}

function _disable-all() {
Expand All @@ -723,8 +725,8 @@ function _disable-plugin() {
_example '$ disable-plugin rvm'
_group 'lib'

_disable-thing "plugins" "plugin" "$1"
_on-disable-callback "$1"
_disable-thing "plugins" "plugin" "${1?}"
_on-disable-callback "${1?}"
}

function _disable-alias() {
Expand All @@ -733,7 +735,7 @@ function _disable-alias() {
_example '$ disable-alias git'
_group 'lib'

_disable-thing "aliases" "alias" "$1"
_disable-thing "aliases" "alias" "${1?}"
}

function _disable-completion() {
Expand All @@ -742,7 +744,7 @@ function _disable-completion() {
_example '$ disable-completion git'
_group 'lib'

_disable-thing "completion" "completion" "$1"
_disable-thing "completion" "completion" "${1?}"
}

function _disable-thing() {
Expand Down Expand Up @@ -776,7 +778,7 @@ function _disable-thing() {
# Either one will be matched by this glob
for plugin in "${BASH_IT}/enabled"/[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash" "${BASH_IT}/$subdirectory/enabled/"{[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash","${file_entity}.${suffix}.bash"}; do
if [[ -e "${plugin}" ]]; then
rm "${plugin}"
rm -f "${plugin}"
plugin=
break
fi
Expand All @@ -789,8 +791,9 @@ function _disable-thing() {

_bash-it-clean-component-cache "${file_type}"

if [[ "$file_entity" = "all" ]]; then
printf '%s\n' "$file_entity $(_bash-it-pluralize-component "$file_type") disabled."
if [[ "$file_entity" == "all" ]]; then
_bash-it-component-pluralize "${file_type}"
printf '%s\n' "$file_entity ${_bash_it_component_pluralize?} disabled."
else
printf '%s\n' "$file_entity disabled."
fi
Expand Down

0 comments on commit 3efc183

Please sign in to comment.