From 4203456c2a6bf0a9ebc9a8b9cdfb328c4b509cdd Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 12 Jun 2017 01:04:18 +0200 Subject: [PATCH] shellcheck linting --- bash_paths | 4 ++-- bash_profile | 2 +- bash_prompt | 2 +- bin/colors.sh | 8 ++++---- bin/install-brew.sh | 4 ++-- bin/install.sh | 30 +++++++++++++++--------------- bin/update-dotfiles.sh | 4 ++-- bin/update-everything.sh | 24 ++++++++++++------------ bin/updaterepos.sh | 2 +- exports | 4 ++++ 10 files changed, 44 insertions(+), 40 deletions(-) diff --git a/bash_paths b/bash_paths index 07abe27..0d0f6dd 100644 --- a/bash_paths +++ b/bash_paths @@ -22,7 +22,7 @@ declare -a dirs_to_append=( # Prepend directories to PATH for index in ${!dirs_to_prepend[*]} do - if [ -d ${dirs_to_prepend[$index]} ]; then + if [ -d "${dirs_to_prepend[$index]}" ]; then # If these directories exist, then prepend them to existing PATH PATH="${dirs_to_prepend[$index]}:$PATH" fi @@ -31,7 +31,7 @@ done # Append directories to PATH for index in ${!dirs_to_append[*]} do - if [ -d ${dirs_to_append[$index]} ]; then + if [ -d "${dirs_to_append[$index]}" ]; then # If these bins exist, then append them to existing PATH PATH="$PATH:${dirs_to_append[$index]}" fi diff --git a/bash_profile b/bash_profile index 642cb3e..57cce7f 100644 --- a/bash_profile +++ b/bash_profile @@ -14,7 +14,7 @@ # Load ~/.private, ~/.bash_prompt # ---------------------------------------------------------------------- -for file in ~/.{bash_paths,bash_prompt,exports,aliases,inputrc,private}; do +for file in ~/.{exports,private,bash_paths,bash_prompt,aliases,inputrc}; do [ -r "$file" ] && [ -f "$file" ] && source "$file" done; unset file; diff --git a/bash_prompt b/bash_prompt index ea90bdb..5abc68a 100644 --- a/bash_prompt +++ b/bash_prompt @@ -17,7 +17,7 @@ prompt_git() { local branchName=''; # Check if the current directory is in a Git repository. - if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then + if [ "$(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}")" == '0' ]; then # check if the current directory is in .git before running git checks if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then diff --git a/bin/colors.sh b/bin/colors.sh index c93b183..ce23e8d 100755 --- a/bin/colors.sh +++ b/bin/colors.sh @@ -5,10 +5,10 @@ echo echo -e "$(tput bold) reg bld und tput-command-colors$(tput sgr0)" for i in $(seq 1 256); do - echo " $(tput setaf $i)Text$(tput sgr0) $(tput bold)$(tput setaf $i)Text$(tput sgr0) $(tput sgr 0 1)$(tput setaf $i)Text$(tput sgr0) \$(tput setaf $i)" + echo " $(tput setaf "$i")Text$(tput sgr0) $(tput bold)$(tput setaf "$i")Text$(tput sgr0) $(tput sgr 0 1)$(tput setaf "$i")Text$(tput sgr0) \$(tput setaf $i)" done -echo ' Bold $(tput bold)' -echo ' Underline $(tput sgr 0 1)' -echo ' Reset $(tput sgr0)' +echo " Bold $(tput bold)" +echo " Underline $(tput sgr 0 1)" +echo " Reset $(tput sgr0)" echo diff --git a/bin/install-brew.sh b/bin/install-brew.sh index d3f8547..47fd1e1 100755 --- a/bin/install-brew.sh +++ b/bin/install-brew.sh @@ -1,7 +1,7 @@ #!/bin/bash # give me /usr/local first -sudo chown -R $USER /usr/local +sudo chown -R "$USER" /usr/local # Install Homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" @@ -18,7 +18,7 @@ brew install bash brew install bash-completion2 # Switch to using brew-installed bash as default shell -if ! fgrep -q '/usr/local/bin/bash' /etc/shells; then +if ! grep -F -q '/usr/local/bin/bash' /etc/shells; then echo '/usr/local/bin/bash' | sudo tee -a /etc/shells; chsh -s /usr/local/bin/bash; fi; diff --git a/bin/install.sh b/bin/install.sh index 0d0b980..9e59e6b 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -31,7 +31,7 @@ touch private # ---------------------------------------------------------------------- for file in $files; do - ln -s $file ~/.$file + ln -s "$file" ~/."$file" echo "$(tput setaf 64)✓$(tput sgr0) Created symlink to $(tput setaf 37)$file$(tput sgr0)" done @@ -45,52 +45,52 @@ source ~/.bash_profile # Homebrew # ---------------------------------------------------------------------- -echo "$(tput setaf 136)" +"$(tput setaf 136)" echo " Brewing all the things. " echo "=============================================" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset bin/install-brew.sh -echo "$(tput setaf 64)" # green +"$(tput setaf 64)" # green echo "---------------------------------------------" echo " ✓ done" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset # ---------------------------------------------------------------------- # npm # ---------------------------------------------------------------------- -echo "$(tput setaf 136)" +"$(tput setaf 136)" echo " npm all the things. " echo "=============================================" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset bin/install-npm.sh -echo "$(tput setaf 64)" # green +"$(tput setaf 64)" # green echo "---------------------------------------------" echo " ✓ done" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset # ---------------------------------------------------------------------- # Ruby # ---------------------------------------------------------------------- -echo "$(tput setaf 136)" +"$(tput setaf 136)" echo " Ruby all the things. " echo "=============================================" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset bin/install-ruby.sh -echo "$(tput setaf 64)" # green +"$(tput setaf 64)" # green echo "---------------------------------------------" echo " ✓ done" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset -echo "$(tput setaf 64)" # green +"$(tput setaf 64)" # green echo "=============================================" echo " ✓ all done" echo "=============================================" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset diff --git a/bin/update-dotfiles.sh b/bin/update-dotfiles.sh index b86b4e7..1ebcb2b 100755 --- a/bin/update-dotfiles.sh +++ b/bin/update-dotfiles.sh @@ -23,7 +23,7 @@ files="aliases bashrc bash_profile bash_paths bash_prompt editorconfig exports g # ---------------------------------------------------------------------- for file in $files; do - rm ~/.$file + rm ~/."$file" done @@ -33,7 +33,7 @@ done # ---------------------------------------------------------------------- for file in $files; do - ln -s $file ~/.$file + ln -s "$file" ~/."$file" echo "$(tput setaf 64)✓$(tput sgr0) Created symlink to $(tput setaf 37)$file$(tput sgr0)" done diff --git a/bin/update-everything.sh b/bin/update-everything.sh index ed295f3..58f0786 100755 --- a/bin/update-everything.sh +++ b/bin/update-everything.sh @@ -5,10 +5,10 @@ # macOS # ------------- -echo "$(tput setaf 136)" +"$(tput setaf 136)" echo "Update macOS Apps " echo "------------------------------" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset #sudo softwareupdate -i -a @@ -18,10 +18,10 @@ mas upgrade # Homebrew # ------------- -echo "$(tput setaf 136)" +"$(tput setaf 136)" echo "Update Homebrew " echo "------------------------------" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset brew update brew upgrade @@ -32,10 +32,10 @@ brew cleanup # npm # ------------- -echo "$(tput setaf 136)" +"$(tput setaf 136)" echo "Update npm " echo "------------------------------" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset # update npm itself npm install npm -g @@ -47,10 +47,10 @@ npm update -g # Ruby # ------------- -echo "$(tput setaf 136)" +"$(tput setaf 136)" echo "Update rvm " echo "------------------------------" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset # update rvm itself rvm get stable @@ -66,14 +66,14 @@ rvm cleanup all # GPG # ------------- -echo "$(tput setaf 136)" +"$(tput setaf 136)" echo "Refresh GPG keys " echo "------------------------------" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset gpg --refresh-keys -echo "$(tput setaf 64)" # green +"$(tput setaf 64)" # green echo "-------------------------------" echo " ✓ all done" -echo "$(tput sgr0)" # reset +"$(tput sgr0)" # reset diff --git a/bin/updaterepos.sh b/bin/updaterepos.sh index 22a43ac..f3db6e5 100755 --- a/bin/updaterepos.sh +++ b/bin/updaterepos.sh @@ -13,7 +13,7 @@ updateRepo() { local dir="$1" local original_dir="$2" - cd $dir # switch to the git repo + cd "$dir" # switch to the git repo repo_url=$(git config --get remote.origin.url) echo "$(tput setaf 136)Updating Repo: $dir with url: $repo_url$(tput sgr0)" diff --git a/exports b/exports index d76dc58..4e10ad6 100644 --- a/exports +++ b/exports @@ -15,3 +15,7 @@ export LSCOLORS=gxfxcxdxbxegedabagacad export PIP_REQUIRE_VIRTUALENV=true # cache pip-installed packages to avoid re-downloading export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache + +# go +export GOPATH=$HOME/.go +export GOROOT=/usr/local/opt/go/libexec \ No newline at end of file