Skip to content
This repository was archived by the owner on Feb 20, 2023. It is now read-only.

Commit bdfb248

Browse files
committed
Allow enable.sh to work with zsh
1 parent 2fd52e5 commit bdfb248

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

Diff for: enable.sh

+28-21
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,7 @@
77
# [user@localhost]$ source enable.sh
88
#
99

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}" ]]
2311
then
2412
echo "You are trying to call this script directly, which is not"
2513
echo "possible. You must source this script instead:"
@@ -29,13 +17,32 @@ then
2917
exit 1
3018
fi
3119

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"
3422

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
3844
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

Comments
 (0)