Fixed a couple of shellcheck complaints

pull/1043/head
Nils Winkler 2017-09-15 08:10:16 +02:00
parent 88ef16ccc7
commit 475b0778dd
1 changed files with 16 additions and 9 deletions

View File

@ -20,7 +20,8 @@ function _load_bash_it_files() {
# In the new structure # In the new structure
if [ -d "${BASH_IT}/enabled" ] if [ -d "${BASH_IT}/enabled" ]
then then
local suffix=$(echo "$subdirectory" | sed -e 's/plugins/plugin/g') declare suffix
suffix=$(echo "$subdirectory" | sed -e 's/plugins/plugin/g')
FILES="${BASH_IT}/enabled/*.${suffix}.bash" FILES="${BASH_IT}/enabled/*.${suffix}.bash"
for config_file in $FILES for config_file in $FILES
@ -75,7 +76,7 @@ bash-it ()
help) help)
func=_help-$component;; func=_help-$component;;
search) search)
_bash-it-search $component $* _bash-it-search $component "$@"
return;; return;;
update) update)
func=_bash-it_update;; func=_bash-it_update;;
@ -101,7 +102,7 @@ bash-it ()
fi fi
fi fi
if [ x"$verb" == x"enable" -o x"$verb" == x"disable" ];then if [ x"$verb" == x"enable" ] || [ x"$verb" == x"disable" ]; then
# Automatically run a migration if required # Automatically run a migration if required
_bash-it-migrate _bash-it-migrate
@ -110,7 +111,7 @@ bash-it ()
$func $arg $func $arg
done done
else else
$func $* $func "$@"
fi fi
} }
@ -150,12 +151,17 @@ _bash-it_update() {
_about 'updates Bash-it' _about 'updates Bash-it'
_group 'lib' _group 'lib'
cd "${BASH_IT}" cd "${BASH_IT}" || return
if [ -z $BASH_IT_REMOTE ]; then if [ -z $BASH_IT_REMOTE ]; then
BASH_IT_REMOTE="origin" BASH_IT_REMOTE="origin"
fi fi
git fetch &> /dev/null git fetch &> /dev/null
local status="$(git rev-list master..${BASH_IT_REMOTE}/master 2> /dev/null)"
declare status
status="$(git rev-list master..${BASH_IT_REMOTE}/master 2> /dev/null)"
if [[ -n "${status}" ]]; then if [[ -n "${status}" ]]; then
git pull --rebase &> /dev/null git pull --rebase &> /dev/null
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
@ -172,7 +178,7 @@ _bash-it_update() {
else else
echo "Bash-it is up to date, nothing to do!" echo "Bash-it is up to date, nothing to do!"
fi fi
cd - &> /dev/null cd - &> /dev/null || return
} }
_bash-it-migrate() { _bash-it-migrate() {
@ -402,8 +408,9 @@ _enable-thing ()
mkdir -p "${BASH_IT}/enabled" mkdir -p "${BASH_IT}/enabled"
# Load the priority from the file if it present there # Load the priority from the file if it present there
local local_file_priority=$(grep -E "^# BASH_IT_LOAD_PRIORITY:" "${BASH_IT}/$subdirectory/available/$to_enable" | awk -F': ' '{ print $2 }') declare local_file_priority use_load_priority
local use_load_priority=${local_file_priority:-$load_priority} local_file_priority=$(grep -E "^# BASH_IT_LOAD_PRIORITY:" "${BASH_IT}/$subdirectory/available/$to_enable" | awk -F': ' '{ print $2 }')
use_load_priority=${local_file_priority:-$load_priority}
ln -s ../$subdirectory/available/$to_enable "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}" ln -s ../$subdirectory/available/$to_enable "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}"
fi fi