From 210c9ac2055566bb7fd8932299b55c29f1ececee Mon Sep 17 00:00:00 2001
From: Jack Nagel <jacknagel@gmail.com>
Date: Sun, 13 May 2012 19:00:10 -0500
Subject: [PATCH] Use 'which' helper method more

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
---
 Library/Homebrew/cmd/--config.rb | 18 +++++++++---------
 Library/Homebrew/cmd/doctor.rb   |  4 ++--
 Library/Homebrew/cmd/info.rb     |  2 +-
 Library/Homebrew/cmd/tap.rb      |  2 +-
 Library/Homebrew/utils.rb        |  4 ++--
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/Library/Homebrew/cmd/--config.rb b/Library/Homebrew/cmd/--config.rb
index 7556955676..abe247cadb 100644
--- a/Library/Homebrew/cmd/--config.rb
+++ b/Library/Homebrew/cmd/--config.rb
@@ -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
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 33e01f0fcc..734f38bdb3 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -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}
 
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index 0a9cb76dbf..3fac9f4340 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -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
diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb
index cadebe8ce5..1f4ec19b59 100644
--- a/Library/Homebrew/cmd/tap.rb
+++ b/Library/Homebrew/cmd/tap.rb
@@ -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
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index f5530c29f7..de797f2d6b 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -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
-- 
GitLab