Use 'which' helper method more
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
28f89c59a2
commit
210c9ac205
@ -45,29 +45,29 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
|
|
||||||
def describe_perl
|
def describe_perl
|
||||||
perl = `which perl`.chomp
|
perl = which 'perl'
|
||||||
return "N/A" if perl.empty?
|
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 if perl == real_perl
|
||||||
return "#{perl} => #{real_perl}"
|
return "#{perl} => #{real_perl}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def describe_python
|
def describe_python
|
||||||
python = `which python`.chomp
|
python = which 'python'
|
||||||
return "N/A" if python.empty?
|
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 if python == real_python
|
||||||
return "#{python} => #{real_python}"
|
return "#{python} => #{real_python}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def describe_ruby
|
def describe_ruby
|
||||||
ruby = `which ruby`.chomp
|
ruby = which 'ruby'
|
||||||
return "N/A" if ruby.empty?
|
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 if ruby == real_ruby
|
||||||
return "#{ruby} => #{real_ruby}"
|
return "#{ruby} => #{real_ruby}"
|
||||||
end
|
end
|
||||||
|
@ -669,9 +669,9 @@ end
|
|||||||
def check_for_autoconf
|
def check_for_autoconf
|
||||||
return if MacOS.xcode_version >= "4.3"
|
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]
|
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:
|
An "autoconf" in your path blocks the Xcode-provided version at:
|
||||||
#{autoconf}
|
#{autoconf}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
|
|
||||||
def github_fork
|
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}
|
if `git remote -v` =~ %r{origin\s+(https?://|git(?:@|://))github.com[:/](.+)/homebrew}
|
||||||
$2
|
$2
|
||||||
end
|
end
|
||||||
|
@ -12,7 +12,7 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install_tap user, repo
|
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
|
# we special case homebrew so users don't have to shift in a terminal
|
||||||
repouser = if user == "homebrew" then "Homebrew" else user end
|
repouser = if user == "homebrew" then "Homebrew" else user end
|
||||||
|
@ -482,8 +482,8 @@ module MacOS extend self
|
|||||||
return false unless MACOS
|
return false unless MACOS
|
||||||
|
|
||||||
%w[port fink].each do |ponk|
|
%w[port fink].each do |ponk|
|
||||||
path = `/usr/bin/which #{ponk} 2>/dev/null`
|
path = which(ponk)
|
||||||
return ponk unless path.empty?
|
return ponk unless path.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
# we do the above check because macports can be relocated and fink may be
|
# we do the above check because macports can be relocated and fink may be
|
||||||
|
Loading…
x
Reference in New Issue
Block a user