266bc17ab3587920a7a98262c78dc5a026583bf3
- Author
- Dennis Dashkevich <dskecse@gmail.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
fix(chruby): avoid adding PATH entries twice (#12980)
Diff
1diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh
2index 06afef189a3ca47d29c590b81f06d40245dd26de..1bcc6c6d94cecfff7e60c85cf266ad757ec6fe88 100644
3--- a/plugins/chruby/chruby.plugin.zsh
4+++ b/plugins/chruby/chruby.plugin.zsh
5@@ -15,6 +15,13 @@ _source-from-omz-settings() {
6 fi
7 }
8
9+_source-from-default-location() {
10+ [[ -r /usr/local/share/chruby/chruby.sh ]] || return 1
11+
12+ source /usr/local/share/chruby/chruby.sh
13+ source /usr/local/share/chruby/auto.sh
14+}
15+
16 _source-from-homebrew() {
17 (( $+commands[brew] )) || return 1
18
19@@ -36,27 +43,14 @@ _source-from-homebrew() {
20 source $_brew_prefix/share/chruby/auto.sh
21 }
22
23-_load-chruby-dirs() {
24- local dir
25- for dir in "$HOME/.rubies" "$PREFIX/opt/rubies"; do
26- if [[ -d "$dir" ]]; then
27- RUBIES+=("$dir")
28- fi
29- done
30-}
31-
32 # Load chruby
33-if _source-from-omz-settings; then
34- _load-chruby-dirs
35-elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
36- source /usr/local/share/chruby/chruby.sh
37- source /usr/local/share/chruby/auto.sh
38- _load-chruby-dirs
39-elif _source-from-homebrew; then
40- _load-chruby-dirs
41-fi
42+_source-from-omz-settings || \
43+ _source-from-default-location || \
44+ _source-from-homebrew
45
46-unfunction _source-from-homebrew _source-from-omz-settings _load-chruby-dirs
47+unfunction _source-from-homebrew \
48+ _source-from-default-location \
49+ _source-from-omz-settings
50
51
52 ## chruby utility functions and aliases