aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Nisbet2016-05-22 16:03:51 -0700
committerGreg Nisbet2016-08-10 23:21:30 -0700
commitf0cc815d86aceec61adca10606124ad840b0398a (patch)
treee6f6839d0531e7be98ed82fdf95450da3e95c1fd
parentf1ce3585511c6c13a0628534c0399a3638f98596 (diff)
downloadbrew-f0cc815d86aceec61adca10606124ad840b0398a.tar.bz2
Multi-shell diagnostic check
-rw-r--r--Library/Homebrew/diagnostic.rb6
-rw-r--r--Library/Homebrew/utils/shell.rb11
2 files changed, 14 insertions, 3 deletions
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index b2f92c5f4..d032ecff5 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -476,7 +476,7 @@ module Homebrew
Consider setting your PATH so that #{HOMEBREW_PREFIX}/bin
occurs before /usr/bin. Here is a one-liner:
- echo 'export PATH="#{HOMEBREW_PREFIX}/bin:$PATH"' >> #{Utils::Shell.shell_profile}
+ #{Utils::Shell.prepend_path_in_shell_profile("#{HOMEBREW_PREFIX}/bin")}
EOS
end
end
@@ -496,7 +496,7 @@ module Homebrew
<<-EOS.undent
Homebrew's bin was not found in your PATH.
Consider setting the PATH for example like so
- echo 'export PATH="#{HOMEBREW_PREFIX}/bin:$PATH"' >> #{Utils::Shell.shell_profile}
+ #{Utils::Shell.prepend_path_in_shell_profile("#{HOMEBREW_PREFIX}/bin:$PATH")}
EOS
end
@@ -511,7 +511,7 @@ module Homebrew
Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in #{HOMEBREW_PREFIX}/sbin.
Consider setting the PATH for example like so
- echo 'export PATH="#{HOMEBREW_PREFIX}/sbin:$PATH"' >> #{Utils::Shell.shell_profile}
+ #{Utils::Shell.prepend_path_in_shell_profile("#{HOMEBREW_PREFIX}/sbin:$PATH")}
EOS
end
diff --git a/Library/Homebrew/utils/shell.rb b/Library/Homebrew/utils/shell.rb
index ca6eace8b..d2301345f 100644
--- a/Library/Homebrew/utils/shell.rb
+++ b/Library/Homebrew/utils/shell.rb
@@ -69,5 +69,16 @@ module Utils
def self.shell_profile
SHELL_PROFILE_MAP.fetch(preferred_shell, "~/.bash_profile")
end
+
+ def self.prepend_path_in_shell_profile(path)
+ case preferred_shell
+ when :bash, :ksh, :sh, :zsh
+ "echo 'export PATH=\"#{sh_quote(path)}:$PATH >> #{shell_profile}"
+ when :csh, :tcsh
+ "echo 'setenv PATH #{csh_quote(path)}:$PATH' >> #{shell_profile}"
+ when :fish
+ "echo 'set -g fish_user_paths $fish_user_paths >> #{sh_quote(path)}' >> #{shell_profile}"
+ end
+ end
end
end