Multi-shell diagnostic check

This commit is contained in:
Greg Nisbet 2016-05-22 16:03:51 -07:00
parent f1ce358551
commit f0cc815d86
2 changed files with 14 additions and 3 deletions

View File

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

View File

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