Fixed missing quotes around $BASH_IT variable

This should fix most issues where Bash-it is installed in a directory
containing spaces.
pull/974/head
Nils Winkler 2017-05-29 07:47:17 +02:00
parent 6f26f92c97
commit 0d9a0987d9
4 changed files with 25 additions and 25 deletions

View File

@ -21,7 +21,7 @@ alias _="sudo"
# colored grep # colored grep
# Need to check an existing file for a pattern that will be found to ensure # Need to check an existing file for a pattern that will be found to ensure
# that the check works when on an OS that supports the color option # that the check works when on an OS that supports the color option
if grep --color=auto "a" $BASH_IT/*.md &> /dev/null if grep --color=auto "a" "${BASH_IT}/"*.md &> /dev/null
then then
alias grep='grep --color=auto' alias grep='grep --color=auto'
export GREP_COLOR='1;33' export GREP_COLOR='1;33'

View File

@ -10,9 +10,9 @@ _bash-it-comp-list-available-not-enabled()
{ {
subdirectory="$1" subdirectory="$1"
local available_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`; local available_things=$(for f in `ls -1 "${BASH_IT}/$subdirectory/available/"*.bash`;
do do
if [ ! -e $BASH_IT/$subdirectory/enabled/$(basename $f) ] && [ ! -e $BASH_IT/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR$(basename $f) ] if [ ! -e "${BASH_IT}/$subdirectory/enabled/"$(basename $f) ] && [ ! -e "${BASH_IT}/$subdirectory/enabled/"*$BASH_IT_LOAD_PRIORITY_SEPARATOR$(basename $f) ]
then then
basename $f | cut -d'.' -f1 basename $f | cut -d'.' -f1
fi fi
@ -25,7 +25,7 @@ _bash-it-comp-list-enabled()
{ {
subdirectory="$1" subdirectory="$1"
local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/enabled/*.bash`; local enabled_things=$(for f in `ls -1 "${BASH_IT}/$subdirectory/enabled/"*.bash`;
do do
basename $f | cut -d'.' -f1 | sed -e "s/^[0-9]*---//g" basename $f | cut -d'.' -f1 | sed -e "s/^[0-9]*---//g"
done) done)
@ -37,7 +37,7 @@ _bash-it-comp-list-available()
{ {
subdirectory="$1" subdirectory="$1"
local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`; local enabled_things=$(for f in `ls -1 "${BASH_IT}/$subdirectory/available/"*.bash`;
do do
basename $f | cut -d'.' -f1 basename $f | cut -d'.' -f1
done) done)

View File

@ -163,7 +163,7 @@ _bash-it-migrate() {
for file_type in "aliases" "plugins" "completion" for file_type in "aliases" "plugins" "completion"
do do
shopt -s nullglob shopt -s nullglob
for f in $BASH_IT/$file_type/enabled/*.bash for f in "${BASH_IT}/$file_type/enabled/"*.bash
do do
typeset ff=$(basename $f) typeset ff=$(basename $f)
@ -203,10 +203,10 @@ _bash-it-describe ()
typeset f typeset f
typeset enabled typeset enabled
printf "%-20s%-10s%s\n" "$column_header" 'Enabled?' 'Description' printf "%-20s%-10s%s\n" "$column_header" 'Enabled?' 'Description'
for f in $BASH_IT/$subdirectory/available/*.bash for f in "${BASH_IT}/$subdirectory/available/"*.bash
do do
# Check for both the old format without the load priority, and the extended format with the priority # Check for both the old format without the load priority, and the extended format with the priority
if [ -e $BASH_IT/$subdirectory/enabled/$(basename $f) ] || [ -e $BASH_IT/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR$(basename $f) ]; then if [ -e "${BASH_IT}/$subdirectory/enabled/"$(basename $f) ] || [ -e "${BASH_IT}/$subdirectory/enabled/"*$BASH_IT_LOAD_PRIORITY_SEPARATOR$(basename $f) ]; then
enabled='x' enabled='x'
else else
enabled=' ' enabled=' '
@ -268,14 +268,14 @@ _disable-thing ()
if [ "$file_entity" = "all" ]; then if [ "$file_entity" = "all" ]; then
typeset f $file_type typeset f $file_type
for f in $BASH_IT/$subdirectory/available/*.bash for f in "${BASH_IT}/$subdirectory/available/"*.bash
do do
plugin=$(basename $f) plugin=$(basename $f)
if [ -e $BASH_IT/$subdirectory/enabled/$plugin ]; then if [ -e "${BASH_IT}/$subdirectory/enabled/$plugin" ]; then
rm $BASH_IT/$subdirectory/enabled/$(basename $plugin) rm "${BASH_IT}/$subdirectory/enabled/$(basename $plugin)"
fi fi
if [ -e $BASH_IT/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR$plugin ]; then if [ -e "${BASH_IT}/$subdirectory/enabled/"*$BASH_IT_LOAD_PRIORITY_SEPARATOR$plugin ]; then
rm $BASH_IT/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR$(basename $plugin) rm "${BASH_IT}/$subdirectory/enabled/"*$BASH_IT_LOAD_PRIORITY_SEPARATOR$(basename $plugin)
fi fi
done done
else else
@ -283,12 +283,12 @@ _disable-thing ()
# 250---node.plugin.bash # 250---node.plugin.bash
# node.plugin.bash # node.plugin.bash
# Either one will be matched by this glob # Either one will be matched by this glob
typeset plugin=$(command ls $BASH_IT/$subdirectory/enabled/{[0-9]*$BASH_IT_LOAD_PRIORITY_SEPARATOR$file_entity.*bash,$file_entity.*bash} 2>/dev/null | head -1) typeset plugin=$(command ls $ "${BASH_IT}/$subdirectory/enabled/"{[0-9]*$BASH_IT_LOAD_PRIORITY_SEPARATOR$file_entity.*bash,$file_entity.*bash} 2>/dev/null | head -1)
if [ -z "$plugin" ]; then if [ -z "$plugin" ]; then
printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type." printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type."
return return
fi fi
rm $BASH_IT/$subdirectory/enabled/$(basename $plugin) rm "${BASH_IT}/$subdirectory/enabled/$(basename $plugin)"
fi fi
if [ -n "$BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE" ]; then if [ -n "$BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE" ]; then
@ -350,13 +350,13 @@ _enable-thing ()
if [ "$file_entity" = "all" ]; then if [ "$file_entity" = "all" ]; then
typeset f $file_type typeset f $file_type
for f in $BASH_IT/$subdirectory/available/*.bash for f in "${BASH_IT}/$subdirectory/available/"*.bash
do do
to_enable=$(basename $f .$file_type.bash) to_enable=$(basename $f .$file_type.bash)
_enable-thing $subdirectory $file_type $to_enable $load_priority _enable-thing $subdirectory $file_type $to_enable $load_priority
done done
else else
typeset to_enable=$(command ls $BASH_IT/$subdirectory/available/$file_entity.*bash 2>/dev/null | head -1) typeset to_enable=$(command ls "${BASH_IT}/$subdirectory/available/"$file_entity.*bash 2>/dev/null | head -1)
if [ -z "$to_enable" ]; then if [ -z "$to_enable" ]; then
printf '%s\n' "sorry, $file_entity does not appear to be an available $file_type." printf '%s\n' "sorry, $file_entity does not appear to be an available $file_type."
return return
@ -364,19 +364,19 @@ _enable-thing ()
to_enable=$(basename $to_enable) to_enable=$(basename $to_enable)
# Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it. # Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it.
typeset enabled_plugin=$(command ls $BASH_IT/$subdirectory/enabled/{[0-9]*$BASH_IT_LOAD_PRIORITY_SEPARATOR$to_enable,$to_enable} 2>/dev/null | head -1) typeset enabled_plugin=$(command ls "${BASH_IT}/$subdirectory/enabled/"{[0-9]*$BASH_IT_LOAD_PRIORITY_SEPARATOR$to_enable,$to_enable} 2>/dev/null | head -1)
if [ ! -z "$enabled_plugin" ] ; then if [ ! -z "$enabled_plugin" ] ; then
printf '%s\n' "$file_entity is already enabled." printf '%s\n' "$file_entity is already enabled."
return return
fi fi
mkdir -p $BASH_IT/$subdirectory/enabled mkdir -p "${BASH_IT}/$subdirectory/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 }') local local_file_priority=$(grep -E "^# BASH_IT_LOAD_PRIORITY:" "${BASH_IT}/$subdirectory/available/$to_enable" | awk -F': ' '{ print $2 }')
local use_load_priority=${local_file_priority:-$load_priority} local use_load_priority=${local_file_priority:-$load_priority}
ln -s ../available/$to_enable $BASH_IT/$subdirectory/enabled/$use_load_priority$BASH_IT_LOAD_PRIORITY_SEPARATOR$to_enable ln -s ../available/$to_enable "${BASH_IT}/$subdirectory/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}"
fi fi
if [ -n "$BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE" ]; then if [ -n "$BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE" ]; then
@ -410,14 +410,14 @@ _help-aliases()
alias_path="available/$1.aliases.bash" alias_path="available/$1.aliases.bash"
;; ;;
esac esac
cat $BASH_IT/aliases/$alias_path | metafor alias | sed "s/$/'/" cat "${BASH_IT}/aliases/$alias_path" | metafor alias | sed "s/$/'/"
else else
typeset f typeset f
for f in $BASH_IT/aliases/enabled/* for f in "${BASH_IT}/aliases/enabled/"*
do do
_help-list-aliases $f _help-list-aliases $f
done done
_help-list-aliases $BASH_IT/aliases/custom.aliases.bash _help-list-aliases "${BASH_IT}/aliases/custom.aliases.bash"
fi fi
} }

View File

@ -14,6 +14,6 @@ then
BASH_IT_THEME=${BASH_IT_THEME##*/} BASH_IT_THEME=${BASH_IT_THEME##*/}
echo " echo "
$BASH_IT_THEME" $BASH_IT_THEME"
echo "" | bash --init-file $BASH_IT/bash_it.sh -i echo "" | bash --init-file "${BASH_IT}/bash_it.sh" -i
done done
fi fi