aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorJack Nagel2012-05-07 20:32:04 -0500
committerJack Nagel2012-05-07 21:05:47 -0500
commit68124d481f7938f3bf280fb92d370a0de9a9b80f (patch)
treef90db02fcdad95975fb43f830343d014563ced16 /Library/Homebrew/utils.rb
parentfa1edd684653e324d36c431fa8bc33b95e651f9e (diff)
downloadbrew-68124d481f7938f3bf280fb92d370a0de9a9b80f.tar.bz2
Unify 'which' and which_s' utility methods
'which' only returns a Pathname or nil, and doesn't care about anything sent to stderr, so just silence it by default and combine the two methods. Closes Homebrew/homebrew#12115. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 3ae8e1181..f5530c29f 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -147,9 +147,8 @@ def puts_columns items, star_items=[]
end
end
-def which cmd, silent=false
- cmd += " 2>/dev/null" if silent
- path = `/usr/bin/which #{cmd}`.chomp
+def which cmd
+ path = `/usr/bin/which #{cmd} 2>/dev/null`.chomp
if path.empty?
nil
else
@@ -157,19 +156,15 @@ def which cmd, silent=false
end
end
-def which_s cmd
- which cmd, true
-end
-
def which_editor
editor = ENV['HOMEBREW_EDITOR'] || ENV['EDITOR']
# If an editor wasn't set, try to pick a sane default
return editor unless editor.nil?
# Find Textmate
- return 'mate' if which_s "mate"
+ return 'mate' if which "mate"
# Find # BBEdit / TextWrangler
- return 'edit' if which_s "edit"
+ return 'edit' if which "edit"
# Default to vim
return '/usr/bin/vim'
end
@@ -405,7 +400,7 @@ module MacOS extend self
# Xcode 4.3 xc* tools hang indefinately if xcode-select path is set thus
raise if `xcode-select -print-path 2>/dev/null`.chomp == "/"
- raise unless which_s "xcodebuild"
+ raise unless which "xcodebuild"
`xcodebuild -version 2>/dev/null` =~ /Xcode (\d(\.\d)*)/
raise if $1.nil? or not $?.success?
$1