From 4510c9ee63703670bbd98fb95efdd8d1f3fbb6e0 Mon Sep 17 00:00:00 2001 From: Benjamin Brombach Date: Tue, 21 Apr 2015 16:17:38 +0200 Subject: [PATCH] fixes #343 by surrounding $HOME (which can have spaces) with quotations marks --- bash_it.sh | 4 ++-- completion/available/dirs.completion.bash | 2 +- completion/available/ssh.completion.bash | 10 +++++----- completion/available/todo.completion.bash | 2 +- completion/available/vagrant.completion.bash | 4 ++-- install.sh | 10 +++++----- plugins/available/nvm.plugin.bash | 2 +- plugins/available/pipsi.plugin.bash | 2 +- plugins/available/rvm.plugin.bash | 2 +- plugins/available/tmuxinator.plugin.bash | 2 +- plugins/available/todo/todo.sh | 2 +- plugins/available/z_autoenv.plugin.bash | 2 +- template/bash_profile.template.bash | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/bash_it.sh b/bash_it.sh index 8557a236..0416306f 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -81,7 +81,7 @@ PREVIEW="less" # Load all the Jekyll stuff -if [ -e $HOME/.jekyllconfig ] +if [ -e "$HOME/.jekyllconfig" ] then - . $HOME/.jekyllconfig + . "$HOME/.jekyllconfig" fi diff --git a/completion/available/dirs.completion.bash b/completion/available/dirs.completion.bash index 67888ebe..ba18db32 100644 --- a/completion/available/dirs.completion.bash +++ b/completion/available/dirs.completion.bash @@ -5,7 +5,7 @@ _dirs-complete() { local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}" # parse all defined shortcuts from ~/.dirs - if [ -r $HOME/.dirs ]; then + if [ -r "$HOME/.dirs" ]; then COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}) ) fi diff --git a/completion/available/ssh.completion.bash b/completion/available/ssh.completion.bash index fd5c6cd5..396be8f2 100644 --- a/completion/available/ssh.completion.bash +++ b/completion/available/ssh.completion.bash @@ -13,14 +13,14 @@ _sshcomplete() { # parse all defined hosts from .ssh/config - if [ -r $HOME/.ssh/config ]; then - COMPREPLY=($(compgen -W "$(grep ^Host $HOME/.ssh/config | awk '{print $2}' )" ${OPTIONS}) ) + if [ -r "$HOME/.ssh/config" ]; then + COMPREPLY=($(compgen -W "$(grep ^Host "$HOME/.ssh/config" | awk '{print $2}' )" ${OPTIONS}) ) fi # parse all hosts found in .ssh/known_hosts - if [ -r $HOME/.ssh/known_hosts ]; then - if grep -v -q -e '^ ssh-rsa' $HOME/.ssh/known_hosts ; then - COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' $HOME/.ssh/known_hosts | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) ) + if [ -r "$HOME/.ssh/known_hosts" ]; then + if grep -v -q -e '^ ssh-rsa' "$HOME/.ssh/known_hosts" ; then + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' "$HOME/.ssh/known_hosts" | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) ) fi fi diff --git a/completion/available/todo.completion.bash b/completion/available/todo.completion.bash index 00493dbc..da365ea6 100644 --- a/completion/available/todo.completion.bash +++ b/completion/available/todo.completion.bash @@ -11,7 +11,7 @@ _todo() mv prepend prep pri p replace report" # Add custom commands from add-ons, if installed. - COMMANDS="$COMMANDS $('ls' ${TODO_ACTIONS_DIR:-$HOME/.todo.actions.d}/ 2>/dev/null)" + COMMANDS="$COMMANDS $('ls' ${TODO_ACTIONS_DIR:-"$HOME/.todo.actions.d"}/ 2>/dev/null)" OPTS="-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x" diff --git a/completion/available/vagrant.completion.bash b/completion/available/vagrant.completion.bash index c5d52283..e0abb7af 100644 --- a/completion/available/vagrant.completion.bash +++ b/completion/available/vagrant.completion.bash @@ -65,7 +65,7 @@ _vagrant() { then case "$prev" in "init") - local box_list=$(find $HOME/.vagrant.d/boxes -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//') + local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//') COMPREPLY=($(compgen -W "${box_list}" -- ${cur})) return 0 ;; @@ -127,7 +127,7 @@ _vagrant() { "box") case "$prev" in "remove"|"repackage") - local box_list=$(find $HOME/.vagrant.d/boxes -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//') + local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//') COMPREPLY=($(compgen -W "${box_list}" -- ${cur})) return 0 ;; diff --git a/install.sh b/install.sh index 1a97b9f3..bbd01411 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,7 @@ esac BACKUP_FILE=$CONFIG_FILE.bak -if [ -e $HOME/$BACKUP_FILE ]; then +if [ -e "$HOME/$BACKUP_FILE" ]; then echo "Backup file already exists. Make sure to backup your .bashrc before running this installation." >&2 while true do @@ -32,11 +32,11 @@ if [ -e $HOME/$BACKUP_FILE ]; then done fi -test -w $HOME/$CONFIG_FILE && - cp -a $HOME/$CONFIG_FILE $HOME/$CONFIG_FILE.bak && +test -w "$HOME/$CONFIG_FILE" && + cp -a "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && echo "Your original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak" -cp $HOME/.bash_it/template/bash_profile.template.bash $HOME/$CONFIG_FILE +cp "$HOME/.bash_it/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE" echo "Copied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it" @@ -95,7 +95,7 @@ else read -e -n 1 -p "Do you use Jekyll? (If you don't know what Jekyll is, answer 'n') [y/N] " RESP case $RESP in [yY]) - cp $HOME/.bash_it/template/jekyllconfig.template.bash $HOME/.jekyllconfig + cp "$HOME/.bash_it/template/jekyllconfig.template.bash" "$HOME/.jekyllconfig" echo "Copied the template .jekyllconfig into your home directory. Edit this file to customize bash-it for using the Jekyll plugins" break ;; diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index 2e607d66..632de967 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -8,7 +8,7 @@ cite about-plugin about-plugin 'node version manager, as a bash function' -export NVM_DIR=$HOME/.nvm +export NVM_DIR="$HOME/.nvm" if [ ! -d "$NVM_DIR" ]; then mkdir $NVM_DIR diff --git a/plugins/available/pipsi.plugin.bash b/plugins/available/pipsi.plugin.bash index 3a645782..305e83cc 100644 --- a/plugins/available/pipsi.plugin.bash +++ b/plugins/available/pipsi.plugin.bash @@ -1,7 +1,7 @@ cite about-plugin about-plugin 'load pipsi, if you are using it' -if [[ -f $HOME/.local/bin/pipsi ]] +if [[ -f "$HOME/.local/bin/pipsi" ]] then export PATH=~/.local/bin:$PATH fi diff --git a/plugins/available/rvm.plugin.bash b/plugins/available/rvm.plugin.bash index 6acad079..ac2598ef 100644 --- a/plugins/available/rvm.plugin.bash +++ b/plugins/available/rvm.plugin.bash @@ -3,7 +3,7 @@ cite about-plugin about-plugin 'load rvm, if you are using it' -[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm +[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Check to make sure that RVM is actually loaded before adding # the customizations to it. diff --git a/plugins/available/tmuxinator.plugin.bash b/plugins/available/tmuxinator.plugin.bash index a0114352..e0dc28f0 100644 --- a/plugins/available/tmuxinator.plugin.bash +++ b/plugins/available/tmuxinator.plugin.bash @@ -1,4 +1,4 @@ cite about-plugin about-plugin 'sources tmuxinator script if available' -[[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && . $HOME/.tmuxinator/scripts/tmuxinator +[[ -s "$HOME/.tmuxinator/scripts/tmuxinator" ]] && . "$HOME/.tmuxinator/scripts/tmuxinator" diff --git a/plugins/available/todo/todo.sh b/plugins/available/todo/todo.sh index 59f88a91..c2e149f0 100755 --- a/plugins/available/todo/todo.sh +++ b/plugins/available/todo/todo.sh @@ -536,7 +536,7 @@ shift $(($OPTIND - 1)) # defaults if not yet defined TODOTXT_VERBOSE=${TODOTXT_VERBOSE:-1} TODOTXT_PLAIN=${TODOTXT_PLAIN:-0} -TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-$HOME/.todo/config} +TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-"$HOME/.todo/config"} TODOTXT_FORCE=${TODOTXT_FORCE:-0} TODOTXT_PRESERVE_LINE_NUMBERS=${TODOTXT_PRESERVE_LINE_NUMBERS:-1} TODOTXT_AUTO_ARCHIVE=${TODOTXT_AUTO_ARCHIVE:-1} diff --git a/plugins/available/z_autoenv.plugin.bash b/plugins/available/z_autoenv.plugin.bash index dd1aec14..553a7ba3 100644 --- a/plugins/available/z_autoenv.plugin.bash +++ b/plugins/available/z_autoenv.plugin.bash @@ -11,7 +11,7 @@ autoenv_init() typeset target home _file typeset -a _files target=$1 - home="$(dirname $HOME)" + home="$(dirname "$HOME")" _files=( $( while [[ "$PWD" != "/" && "$PWD" != "$home" ]] diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 35104ece..9fda847e 100755 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Path to the bash it configuration -export BASH_IT=$HOME/.bash_it +export BASH_IT="$HOME/.bash_it" # Lock and Load a custom theme file # location /.bash_it/themes/