`hub` is crashing for me on a old CentOS setup with
"undefined method `shelljoin'".
On first use of the `git` function it is now checked if
`hub --version` returns successfully.
... | ... |
@@ -1,7 +1,17 @@ |
1 | 1 |
# Setup hub function for git, if it is available; http://github.com/defunkt/hub |
2 | 2 |
if [ "$commands[(I)hub]" ] && [ "$commands[(I)ruby]" ]; then |
3 | 3 |
# eval `hub alias -s zsh` |
4 |
- function git(){hub "$@"} |
|
4 |
+ function git(){ |
|
5 |
+ if ! (( $+_has_working_hub )); then |
|
6 |
+ hub --version &> /dev/null |
|
7 |
+ _has_working_hub=$(($? == 0)) |
|
8 |
+ fi |
|
9 |
+ if (( $_has_working_hub )) ; then |
|
10 |
+ hub "$@" |
|
11 |
+ else |
|
12 |
+ command git "$@" |
|
13 |
+ fi |
|
14 |
+ } |
|
5 | 15 |
fi |
6 | 16 |
|
7 | 17 |
# Functions ################################################################# |