diff options
| author | Mike McQuaid | 2012-03-16 15:14:20 +1300 |
|---|---|---|
| committer | Mike McQuaid | 2012-03-18 15:43:39 +1300 |
| commit | 9c16145d8c22e856ef7dca0ebcfca9519392687a (patch) | |
| tree | dd382b96e56444a9c2b8ed8520c80e629d60998f /Library/Homebrew/utils.rb | |
| parent | b27b761931b987b9dd8a9fc080bbf35270af7cca (diff) | |
| download | homebrew-9c16145d8c22e856ef7dca0ebcfca9519392687a.tar.bz2 | |
Set MACOS_VERSION as 0 on non-OSX platforms.
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index b335c45ea..9b1980149 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -138,7 +138,8 @@ def puts_columns items, star_items=[] end end -def which cmd +def which cmd, silent=false + cmd += " 2>/dev/null" if silent path = `/usr/bin/which #{cmd}`.chomp if path.empty? nil @@ -147,15 +148,19 @@ def which cmd 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 system "/usr/bin/which -s mate" + return 'mate' if which_s "mate" # Find # BBEdit / TextWrangler - return 'edit' if system "/usr/bin/which -s edit" + return 'edit' if which_s "edit" # Default to vim return '/usr/bin/vim' end @@ -378,6 +383,8 @@ module MacOS extend self def xcode_version @xcode_version ||= begin + return "0" unless MACOS + # this shortcut makes xcode_version work for people who don't realise you # need to install the CLI tools xcode43build = "/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild" @@ -389,7 +396,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 system "/usr/bin/which -s xcodebuild" + raise unless which_s "xcodebuild" `xcodebuild -version 2>/dev/null` =~ /Xcode (\d(\.\d)*)/ raise if $1.nil? or not $?.success? $1 @@ -468,9 +475,10 @@ module MacOS extend self # http://github.com/mxcl/homebrew/issues/#issue/13 # http://github.com/mxcl/homebrew/issues/#issue/41 # http://github.com/mxcl/homebrew/issues/#issue/48 + return false unless MACOS %w[port fink].each do |ponk| - path = `/usr/bin/which -s #{ponk}` + path = `/usr/bin/which #{ponk} 2>/dev/null` return ponk unless path.empty? end |
