Skip to content

Commit 1bcc3f4

Browse files
committed
lib/helpers: handle unbound parameters
1 parent 00de143 commit 1bcc3f4

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/helpers.bash

+12-9
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ _bash-it-profile-load-parse-profile() {
572572
break
573573
fi
574574
# Do not actually modify config on dry run
575-
[[ -z $2 ]] || continue
575+
[[ -z ${2:-} ]] || continue
576576
# Actually enable the component
577577
$enable_func "$component"
578578
done < "$1"
@@ -704,7 +704,9 @@ function _on-disable-callback() {
704704
_group 'lib'
705705

706706
local callback="${1}_on_disable"
707-
_command_exists "$callback" && "$callback"
707+
if _command_exists "$callback"; then
708+
"$callback"
709+
fi
708710
}
709711

710712
function _disable-all() {
@@ -723,8 +725,8 @@ function _disable-plugin() {
723725
_example '$ disable-plugin rvm'
724726
_group 'lib'
725727

726-
_disable-thing "plugins" "plugin" "$1"
727-
_on-disable-callback "$1"
728+
_disable-thing "plugins" "plugin" "${1?}"
729+
_on-disable-callback "${1?}"
728730
}
729731

730732
function _disable-alias() {
@@ -733,7 +735,7 @@ function _disable-alias() {
733735
_example '$ disable-alias git'
734736
_group 'lib'
735737

736-
_disable-thing "aliases" "alias" "$1"
738+
_disable-thing "aliases" "alias" "${1?}"
737739
}
738740

739741
function _disable-completion() {
@@ -742,7 +744,7 @@ function _disable-completion() {
742744
_example '$ disable-completion git'
743745
_group 'lib'
744746

745-
_disable-thing "completion" "completion" "$1"
747+
_disable-thing "completion" "completion" "${1?}"
746748
}
747749

748750
function _disable-thing() {
@@ -776,7 +778,7 @@ function _disable-thing() {
776778
# Either one will be matched by this glob
777779
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
778780
if [[ -e "${plugin}" ]]; then
779-
rm "${plugin}"
781+
rm -f "${plugin}"
780782
plugin=
781783
break
782784
fi
@@ -789,8 +791,9 @@ function _disable-thing() {
789791

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

792-
if [[ "$file_entity" = "all" ]]; then
793-
printf '%s\n' "$file_entity $(_bash-it-pluralize-component "$file_type") disabled."
794+
if [[ "$file_entity" == "all" ]]; then
795+
_bash-it-component-pluralize "${file_type}"
796+
printf '%s\n' "$file_entity ${_bash_it_component_pluralize?} disabled."
794797
else
795798
printf '%s\n' "$file_entity disabled."
796799
fi

0 commit comments

Comments
 (0)