Setting up a development environment - 2 This is the new code after following the advice from here:

Setting up a development environment

General feedback is requested.  Also, should I be using $() or () for my sub-shell.  What is the difference.

#
#
#
# Divider - configures bash, git, grunt, sublime and chrome
#
#
#


user1=foo

config_bash() {
    rm ~/.bash_profile
    ln -sf ~/root/config/bash/login.sh ~/.bash_profile
    source ~/.bash_profile
    echo "Bash configured."
}
config_git() {
    local a
    if [ $# -eq 0 ]
    then
        a="client"
    fi

    if [ $# -eq 1 ]
    then
        a="$1"
    fi

    if [ $# -gt 1 ]
    then
        a="$1"
        echo "Git-tooo many arguments"
    fi

    git config --global user.name "$a"
    git config --global user.email "$a@$a.com"    

    git config --global push.default matching
    git config --global core.editor "subl"

    git remote add godaddy $user1@arcmarks.com:~/root.git
    git remote add heroku https://git.heroku.com/frozen-dusk-2587.git
    echo "Git configured."   
}
config_grunt() {
    sudo npm install -g grunt-cli
    mkdir -p ~/root_install/grunt
    ln -sf ~/root/config/grunt/package.json ~/root_install/grunt/package.json
    ln -sf ~/root/config/grunt/Gruntfile.js ~/root_install/grunt/Gruntfile.js
    (cd ~/root_install/grunt; npm install)
    cd ~/root
    echo "Grunt configured."
} 
config_sublime_2() {
    ln -sf /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
    rm -rf ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User
    ln -sf ~/root/config/sublime ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User
    echo "Sublime configured."
}
reset_sublime_2() {
    rm -rf ~/Library/Application\ Support/Sublime\ Text\ 2
}
config_chrome(){
    chmod 0444 ~/Library/Application\ Support/Google/Chrome/Default/History
    echo "Chrome configured."
}
config_all() {
    config_bash
    config_git
    config_grunt
    config_sublime_2
    config_chrome
    list
}
list(){
    local bash=$(which bash) git=$(which git) grunt=$(which grunt) subl=$(which subl)
    local node=$(which node)  heroku=$(which heroku)
    echo "****"    
    echo "Your bash executble is here: $bash."    
    echo "Your git executble is here: $git."    
    echo "Your grunt executble is here: $grunt."
    echo "Your sublime executble is here: $subl."
    echo "Your node executble is here: $node."
    echo "Your heroku executble is here: $heroku."
    echo "****"
}
These conditions are mutually exclusive, so they should be chained using elif:


if [ $# -eq 0 ]
then
    a="client"
fi

if [ $# -eq 1 ]
then
    a="$1"
fi

if [ $# -gt 1 ]
then
    a="$1"
    echo "Git-tooo many arguments"
fi



Like this:

if [ $# -eq 0 ]
then
    a="client"
elif [ $# -eq 1 ]
then
    a="$1"
else
    a="$1"
    echo "Git-tooo many arguments"
fi


This avoids unnecessary evaluations. That is, when $# is 0, only the first condition will be evaluated, the others won't be. In your original code, all conditions will be evaluated always.



As mentioned in the previous review, changing directory inside a script is not recommended. In config_grunt you have this as the last statement of the function:

cd ~/root


It seems pointless, and as it doesn't seem to have anything to do with configuring grunt, it probably shouldn't be in this function.