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 9, 2022
1 parent 00de143 commit 1bcc3f4
Showing 1 changed file with 12 additions and 9 deletions.
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 1bcc3f4

Please sign in to comment.