Skip to content
Snippets Groups Projects
Commit 210c9ac2 authored by Jack Nagel's avatar Jack Nagel
Browse files

Use 'which' helper method more


Signed-off-by: default avatarJack Nagel <jacknagel@gmail.com>
parent 28f89c59
No related branches found
No related tags found
No related merge requests found
......@@ -45,29 +45,29 @@ module Homebrew extend self
end
def describe_perl
perl = `which perl`.chomp
return "N/A" if perl.empty?
perl = which 'perl'
return "N/A" if perl.nil?
real_perl = Pathname.new(perl).realpath.to_s
real_perl = Pathname.new(perl).realpath
return perl if perl == real_perl
return "#{perl} => #{real_perl}"
end
def describe_python
python = `which python`.chomp
return "N/A" if python.empty?
python = which 'python'
return "N/A" if python.nil?
real_python = Pathname.new(python).realpath.to_s
real_python = Pathname.new(python).realpath
return python if python == real_python
return "#{python} => #{real_python}"
end
def describe_ruby
ruby = `which ruby`.chomp
return "N/A" if ruby.empty?
ruby = which 'ruby'
return "N/A" if ruby.nil?
real_ruby = Pathname.new(ruby).realpath.to_s
real_ruby = Pathname.new(ruby).realpath
return ruby if ruby == real_ruby
return "#{ruby} => #{real_ruby}"
end
......
......@@ -669,9 +669,9 @@ end
def check_for_autoconf
return if MacOS.xcode_version >= "4.3"
autoconf = `/usr/bin/which autoconf`.chomp
autoconf = which('autoconf')
safe_autoconfs = %w[/usr/bin/autoconf /Developer/usr/bin/autoconf]
unless autoconf.empty? or safe_autoconfs.include? autoconf then <<-EOS.undent
unless autoconf.nil? or safe_autoconfs.include? autoconf.to_s then <<-EOS.undent
An "autoconf" in your path blocks the Xcode-provided version at:
#{autoconf}
......
......@@ -21,7 +21,7 @@ module Homebrew extend self
end
def github_fork
if system "/usr/bin/which -s git"
if which 'git'
if `git remote -v` =~ %r{origin\s+(https?://|git(?:@|://))github.com[:/](.+)/homebrew}
$2
end
......
......@@ -12,7 +12,7 @@ module Homebrew extend self
end
def install_tap user, repo
raise "brew install git" unless system "/usr/bin/which -s git"
raise "brew install git" unless which 'git'
# we special case homebrew so users don't have to shift in a terminal
repouser = if user == "homebrew" then "Homebrew" else user end
......
......@@ -482,8 +482,8 @@ module MacOS extend self
return false unless MACOS
%w[port fink].each do |ponk|
path = `/usr/bin/which #{ponk} 2>/dev/null`
return ponk unless path.empty?
path = which(ponk)
return ponk unless path.nil?
end
# we do the above check because macports can be relocated and fink may be
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment