reloader: `shellcheck` && `shfmt`
Rewrite globbing per `shellcheck`'s SC2013 recommendations, and standardize whitespace.pull/2055/head
parent
75d22d865f
commit
fd7b20b8d7
|
|
@ -18,6 +18,7 @@
|
||||||
#
|
#
|
||||||
docs/
|
docs/
|
||||||
hooks/
|
hooks/
|
||||||
|
scripts/
|
||||||
|
|
||||||
# root files
|
# root files
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,53 @@
|
||||||
#!/bin/bash
|
# shellcheck shell=bash
|
||||||
|
#
|
||||||
|
# The core component loader.
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
BASH_IT_LOG_PREFIX="core: reloader: "
|
BASH_IT_LOG_PREFIX="core: reloader: "
|
||||||
|
|
||||||
if [[ "$1" != "skip" ]] && [[ -d "$BASH_IT/enabled" ]]; then
|
if [[ "${1:-}" != "skip" ]] && [[ -d "${BASH_IT?}/enabled" ]]; then
|
||||||
_bash_it_config_type=""
|
_bash_it_config_type=""
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
alias|completion|plugin)
|
alias | completion | plugin)
|
||||||
_bash_it_config_type=$1
|
_bash_it_config_type=$1
|
||||||
_log_debug "Loading enabled $1 components..." ;;
|
_log_debug "Loading enabled $1 components..."
|
||||||
''|*)
|
;;
|
||||||
_log_debug "Loading all enabled components..." ;;
|
'' | *)
|
||||||
esac
|
_log_debug "Loading all enabled components..."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
for _bash_it_config_file in $(sort <(compgen -G "$BASH_IT/enabled/*${_bash_it_config_type}.bash")); do
|
for _bash_it_config_file in "$BASH_IT/enabled"/*"${_bash_it_config_type}.bash"; do
|
||||||
if [ -e "${_bash_it_config_file}" ]; then
|
if [[ -e "${_bash_it_config_file}" ]]; then
|
||||||
_bash-it-log-prefix-by-path "${_bash_it_config_file}"
|
_bash-it-log-prefix-by-path "${_bash_it_config_file}"
|
||||||
_log_debug "Loading component..."
|
_log_debug "Loading component..."
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source $_bash_it_config_file
|
source "$_bash_it_config_file"
|
||||||
else
|
_log_debug "Loaded."
|
||||||
echo "Unable to read ${_bash_it_config_file}" > /dev/stderr
|
else
|
||||||
fi
|
_log_error "Unable to read ${_bash_it_config_file}"
|
||||||
done
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${2}" ]] && [[ -d "$BASH_IT/${2}/enabled" ]]; then
|
if [[ -n "${2:-}" ]] && [[ -d "$BASH_IT/${2}/enabled" ]]; then
|
||||||
case $2 in
|
case $2 in
|
||||||
aliases|completion|plugins)
|
aliases | completion | plugins)
|
||||||
_log_warning "Using legacy enabling for $2, please update your bash-it version and migrate"
|
_log_warning "Using legacy enabling for $2, please update your bash-it version and migrate"
|
||||||
for _bash_it_config_file in $(sort <(compgen -G "$BASH_IT/${2}/enabled/*.bash")); do
|
for _bash_it_config_file in "$BASH_IT/${2}/enabled"/*.bash; do
|
||||||
if [[ -e "$_bash_it_config_file" ]]; then
|
if [[ -e "$_bash_it_config_file" ]]; then
|
||||||
_bash-it-log-prefix-by-path "${_bash_it_config_file}"
|
_bash-it-log-prefix-by-path "${_bash_it_config_file}"
|
||||||
_log_debug "Loading component..."
|
_log_debug "Loading component..."
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "$_bash_it_config_file"
|
source "$_bash_it_config_file"
|
||||||
else
|
_log_debug "Loaded."
|
||||||
echo "Unable to locate ${_bash_it_config_file}" > /dev/stderr
|
else
|
||||||
fi
|
_log_error "Unable to locate ${_bash_it_config_file}"
|
||||||
done ;;
|
fi
|
||||||
esac
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset _bash_it_config_file
|
unset _bash_it_config_file
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue