From 8847a8a34b77acc9f7e12dd4ea4fb57e256269da Mon Sep 17 00:00:00 2001 From: kevin lui Date: Fri, 5 Jul 2019 15:27:11 -0700 Subject: [PATCH 1/2] Allow enable.sh to work with zsh --- enable.sh | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/enable.sh b/enable.sh index e78915b..e3da5bd 100644 --- a/enable.sh +++ b/enable.sh @@ -7,19 +7,7 @@ # [user@localhost]$ source enable.sh # -if [ -z $BASH_VERSION ] -then - echo "This script only works if you use bash, aborting." - exit 1 -fi - -if [ ${BASH_VERSINFO[0]} -le 2 ] -then - echo 'Your bash version is too old.' - exit 1 -fi - -if [ "${BASH_SOURCE[0]}" == "${0}" ] +if [[ "${BASH_SOURCE[0]}" == "${0}" ]] then echo "You are trying to call this script directly, which is not" echo "possible. You must source this script instead:" @@ -29,13 +17,32 @@ then exit 1 fi -GIT_TRAC_DIR=`cd $(dirname -- $BASH_SOURCE)/bin && pwd -P` -GIT_TRAC_CMD="$GIT_TRAC_DIR/git-trac" +function set_path_git_trac { + GIT_TRAC_CMD="$GIT_TRAC_DIR/git-trac" -if [ "$(command -v git-trac)" == "$GIT_TRAC_CMD" ] -then - echo "The git-trac command is already in your search PATH" + if [[ "$(command -v git-trac)" == "$GIT_TRAC_CMD" ]] + then + echo "The git-trac command is already in your search PATH" + else + echo "Prepending the git-trac command to your search PATH" + export PATH="$GIT_TRAC_DIR":$PATH + fi +} + +if [[ -n $BASH_VERSION ]]; then + # Assume bash + if [[ ${BASH_VERSINFO[0]} -le 2 ]] + then + echo 'Your bash version is too old.' + fi + GIT_TRAC_DIR=`cd $(dirname -- $BASH_SOURCE)/bin && pwd -P` + set_path_git_trac +elif [[ -n $ZSH_VERSION ]]; then + # Assume zsh + GIT_TRAC_DIR=`cd $(dirname -- ${(%):-%x})/bin && pwd -P` + set_path_git_trac else - echo "Prepending the git-trac command to your search PATH" - export PATH="$GIT_TRAC_DIR":$PATH -fi + echo "This script only works if you use bash or zsh, aborting." +fi + +unset set_path_git_trac From cf925dac325683162bdc5da011551199d51503a1 Mon Sep 17 00:00:00 2001 From: kevin lui Date: Wed, 14 Aug 2019 16:11:06 -0700 Subject: [PATCH 2/2] Remove comment stating zsh doesn't work --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index a1f8c63..371f373 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,6 @@ change is made: $ source git-trac-command/enable.sh Prepending the git-trac command to your search PATH -**Note for `zsh` users:** `enable.sh` requires bash. Use one of the other options described below. - To permanently install the code from this repo, clone it and run ``setup.py``: