From 77062411d5b0cf9db05dea16e825e991e6184361 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 20 Aug 2013 12:56:53 +1200 Subject: Remove unnecessary quoting in simple assignments --- bash/bashrc.d/cd.bash | 2 +- bash/bashrc.d/grep.bash | 4 ++-- bash/bashrc.d/ls.bash | 4 ++-- bash/bashrc.d/prompt.bash | 44 +++++++++++++++++++++----------------------- install | 2 +- sh/profile | 2 +- sh/profile.d/keychain.sh | 2 +- 7 files changed, 29 insertions(+), 31 deletions(-) diff --git a/bash/bashrc.d/cd.bash b/bash/bashrc.d/cd.bash index 282e1649..320d614b 100644 --- a/bash/bashrc.d/cd.bash +++ b/bash/bashrc.d/cd.bash @@ -3,7 +3,7 @@ __cd() { local -a opts while getopts elP opt; do - opts[${#opts[@]}]="-$opt" + opts[${#opts[@]}]=-$opt done shift $(($OPTIND-1)) if (($# == 2)); then diff --git a/bash/bashrc.d/grep.bash b/bash/bashrc.d/grep.bash index 4bd2ed5e..e3efe13c 100644 --- a/bash/bashrc.d/grep.bash +++ b/bash/bashrc.d/grep.bash @@ -5,7 +5,7 @@ __grepopts() { local -a grepopts # Snarf the output of `grep --help` into a variable - local grephelp="$(grep --help 2>/dev/null)" + local grephelp=$(grep --help 2>/dev/null) # Add option to ignore binary files grepopts[${#grepopts[@]}]='-I' @@ -22,7 +22,7 @@ __grepopts() { # If the --color option is available and we have a terminal that supports # at least eight colors, add --color=auto to the options - local -i colors="$(tput colors)" + local -i colors=$(tput colors) if [[ $grephelp == *--color* ]] && ((colors >= 8)); then grepopts[${#grepopts[@]}]='--color=auto' fi diff --git a/bash/bashrc.d/ls.bash b/bash/bashrc.d/ls.bash index 93d6a9ec..4890d1ac 100644 --- a/bash/bashrc.d/ls.bash +++ b/bash/bashrc.d/ls.bash @@ -5,11 +5,11 @@ __lsopts() { local -a lsopts # Snarf the output of `ls --help` into a variable - local lshelp="$(ls --help 2>/dev/null)" + local lshelp=$(ls --help 2>/dev/null) # If the --color option is available and we have a terminal that supports # at least eight colors, add --color=auto to the options - local -i colors="$(tput colors)" + local -i colors=$(tput colors) if [[ $lshelp == *--color* ]] && ((colors >= 8)); then lsopts[${#lsopts[@]}]='--color=auto' fi diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 23c9d64b..74eae891 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -2,7 +2,7 @@ prompt() { # Variables for use only within this function - local -i ret=$? colors="$(tput colors)" + local -i ret=$? colors=$(tput colors) local color reset branch state info url root # What's done next depends on the first argument to the function @@ -15,15 +15,15 @@ prompt() { # Check if we have non-bold bright green available if ((colors > 8)); then - color="$(tput setaf 10)" + color=$(tput setaf 10) # If we don't, fall back to the bold green else - color="$(tput setaf 2)$(tput bold)" + color=$(tput setaf 2)$(tput bold) fi # Reset color and attributes - reset="$(tput sgr0)" + reset=$(tput sgr0) # String it all together PS1="\\[$color\\]$PS1\\[$reset\\] " @@ -54,32 +54,32 @@ prompt() { # Figure out the branch to show for HEAD, whether a symbolic # reference or a short SHA-1; chop off any leading path - branch="$(git symbolic-ref --quiet HEAD 2>/dev/null)" \ - || branch="$(git rev-parse --short HEAD 2>/dev/null)" \ + branch=$(git symbolic-ref --quiet HEAD 2>/dev/null) \ + || branch=$(git rev-parse --short HEAD 2>/dev/null) \ || branch='unknown' - branch="${branch##*/}" + branch=${branch##*/} # If there are staged changes in the working tree, add a plus sign # to the state if ! git diff --quiet --ignore-submodules --cached; then - state="${state}+" + state=$state+ fi # If there are any modified tracked files in the working tree, add # an exclamation mark to the state if ! git diff-files --quiet --ignore-submodules --; then - state="${state}!" + state=$state! fi # If there are any stashed changes, add a circumflex to the state if $(git rev-parse --verify refs/stash &>/dev/null); then - state="${state}^" + state=$state^ fi # If there are any new unignored files in the working tree, add a # question mark to the state if [ -n "$(git ls-files --others --exclude-standard)" ]; then - state="${state}?" + state=$state? fi # Print the status in brackets with a git: prefix @@ -90,14 +90,14 @@ prompt() { hg) # Exit if not inside a Mercurial tree - if ! branch="$(hg branch 2>/dev/null)"; then + if ! branch=$(hg branch 2>/dev/null); then return 1 fi # If there are changes in the tree, add an exclamation mark to the # state if [[ -n $(hg status 2>/dev/null) ]]; then - state="!" + state=! fi # Print the status in brackets with an hg: prefix @@ -113,24 +113,22 @@ prompt() { fi # Determine the repository URL and root directory - info="$(svn info 2>/dev/null)" - url="$(awk -F': ' '$1 == "URL" {print $2}' \ - <<<"$info")" - root="$(awk -F': ' '$1 == "Repository Root" {print $2}' \ - <<<"$info")" + info=$(svn info 2>/dev/null) + url=$(awk -F': ' '$1 == URL" {print $2}' <<<"$info") + root=$(awk -F': ' '$1 == "Repository Root" {print $2}' <<<"$info") # Remove the root from the URL to get what's hopefully the branch # name, removing leading slashes and the 'branches' prefix, and any # trailing content after a slash - branch="${url/$root}" - branch="${branch#/}" - branch="${branch#branches/}" - branch="${branch%%/*}" + branch=${url/$root} + branch=${branch#/} + branch=${branch#branches/} + branch=${branch%%/*} # If there are changes in the working directory, add an exclamation # mark to the state if [[ -n $(svn status 2>/dev/null) ]]; then - state="!" + state=! fi # Print the state in brackets with an svn: prefix diff --git a/install b/install index b930c9a7..a34d5e36 100755 --- a/install +++ b/install @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Define dotfiles directory and check it exists -dotfiles="$HOME/.dotfiles" +dotfiles=$HOME/.dotfiles if [[ ! -d $dotfiles ]]; then printf "Could not find $dotfiles!\n" >&2 exit 1 diff --git a/sh/profile b/sh/profile index 14b0a56b..164d765c 100644 --- a/sh/profile +++ b/sh/profile @@ -1,6 +1,6 @@ # Set editor EDITOR='vi' -VISUAL="$EDITOR" +VISUAL=$EDITOR export EDITOR VISUAL # Set pager diff --git a/sh/profile.d/keychain.sh b/sh/profile.d/keychain.sh index 711c8286..812143f4 100644 --- a/sh/profile.d/keychain.sh +++ b/sh/profile.d/keychain.sh @@ -1,6 +1,6 @@ # ssh-askpass setup if command -v ssh-askpass >/dev/null 2>&1; then - SSH_ASKPASS="$(command -v ssh-askpass)" + SSH_ASKPASS=$(command -v ssh-askpass) export SSH_ASKPASS fi -- cgit v1.2.3