|
7 | 7 | # [user@localhost]$ source enable.sh
|
8 | 8 | #
|
9 | 9 |
|
10 |
| -if [ -z $BASH_VERSION ] |
11 |
| -then |
12 |
| - echo "This script only works if you use bash, aborting." |
13 |
| - exit 1 |
14 |
| -fi |
15 |
| - |
16 |
| -if [ ${BASH_VERSINFO[0]} -le 2 ] |
17 |
| -then |
18 |
| - echo 'Your bash version is too old.' |
19 |
| - exit 1 |
20 |
| -fi |
21 |
| - |
22 |
| -if [ "${BASH_SOURCE[0]}" == "${0}" ] |
| 10 | +if [[ "${BASH_SOURCE[0]}" == "${0}" ]] |
23 | 11 | then
|
24 | 12 | echo "You are trying to call this script directly, which is not"
|
25 | 13 | echo "possible. You must source this script instead:"
|
|
29 | 17 | exit 1
|
30 | 18 | fi
|
31 | 19 |
|
32 |
| -GIT_TRAC_DIR=`cd $(dirname -- $BASH_SOURCE)/bin && pwd -P` |
33 |
| -GIT_TRAC_CMD="$GIT_TRAC_DIR/git-trac" |
| 20 | +function set_path_git_trac { |
| 21 | + GIT_TRAC_CMD="$GIT_TRAC_DIR/git-trac" |
34 | 22 |
|
35 |
| -if [ "$(command -v git-trac)" == "$GIT_TRAC_CMD" ] |
36 |
| -then |
37 |
| - echo "The git-trac command is already in your search PATH" |
| 23 | + if [[ "$(command -v git-trac)" == "$GIT_TRAC_CMD" ]] |
| 24 | + then |
| 25 | + echo "The git-trac command is already in your search PATH" |
| 26 | + else |
| 27 | + echo "Prepending the git-trac command to your search PATH" |
| 28 | + export PATH="$GIT_TRAC_DIR":$PATH |
| 29 | + fi |
| 30 | +} |
| 31 | + |
| 32 | +if [[ -n $BASH_VERSION ]]; then |
| 33 | + # Assume bash |
| 34 | + if [[ ${BASH_VERSINFO[0]} -le 2 ]] |
| 35 | + then |
| 36 | + echo 'Your bash version is too old.' |
| 37 | + fi |
| 38 | + GIT_TRAC_DIR=`cd $(dirname -- $BASH_SOURCE)/bin && pwd -P` |
| 39 | + set_path_git_trac |
| 40 | +elif [[ -n $ZSH_VERSION ]]; then |
| 41 | + # Assume zsh |
| 42 | + GIT_TRAC_DIR=`cd $(dirname -- ${(%):-%x})/bin && pwd -P` |
| 43 | + set_path_git_trac |
38 | 44 | else
|
39 |
| - echo "Prepending the git-trac command to your search PATH" |
40 |
| - export PATH="$GIT_TRAC_DIR":$PATH |
41 |
| -fi |
| 45 | + echo "This script only works if you use bash or zsh, aborting." |
| 46 | +fi |
| 47 | + |
| 48 | +unset set_path_git_trac |
0 commit comments