diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb index b4c99a7e63..1940ff2727 100644 --- a/Library/Homebrew/cmd/doctor.rb +++ b/Library/Homebrew/cmd/doctor.rb @@ -633,7 +633,7 @@ def check_for_multiple_volumes end def check_for_git - unless which_s "git" then <<-EOS.undent + unless which "git" then <<-EOS.undent Git could not be found in your PATH. Homebrew uses Git for several internal functions, and some formulae use Git checkouts instead of stable tarballs. You may want to install Git: @@ -643,7 +643,7 @@ def check_for_git end def check_git_newline_settings - return unless which_s "git" + return unless which "git" autocrlf = `git config --get core.autocrlf`.chomp safecrlf = `git config --get core.safecrlf`.chomp @@ -774,7 +774,7 @@ def check_missing_deps end def check_git_status - return unless which_s "git" + return unless which "git" HOMEBREW_REPOSITORY.cd do unless `git status -s -- Library/Homebrew/ 2>/dev/null`.chomp.empty? then <<-EOS.undent You have uncommitted modifications to Homebrew's core. @@ -803,7 +803,7 @@ end def check_git_version # see https://github.com/blog/642-smart-http-support - return unless which_s "git" + return unless which "git" `git --version`.chomp =~ /git version (\d)\.(\d)\.(\d)/ if $2.to_i < 6 or $2.to_i == 6 and $3.to_i < 6 then <<-EOS.undent @@ -815,7 +815,7 @@ def check_git_version end def check_for_enthought_python - if which_s "enpkg" then <<-EOS.undent + if which "enpkg" then <<-EOS.undent Enthought Python was found in your PATH. This can cause build problems, as this software installs its own copies of iconv and libxml2 into directories that are picked up by @@ -825,7 +825,7 @@ def check_for_enthought_python end def check_for_bad_python_symlink - return unless which_s "python" + return unless which "python" # Indeed Python --version outputs to stderr (WTF?) `python --version 2>&1` =~ /Python (\d+)\./ unless $1 == "2" then <<-EOS.undent diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 26edaf2042..428014291c 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -4,7 +4,7 @@ require 'cmd/untap' module Homebrew extend self def update - abort "Please `brew install git' first." unless which_s "git" + abort "Please `brew install git' first." unless which "git" # ensure GIT_CONFIG is unset as we need to operate on .git/config ENV.delete('GIT_CONFIG') diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index ba312ab6f0..2675511064 100644 --- a/Library/Homebrew/cmd/versions.rb +++ b/Library/Homebrew/cmd/versions.rb @@ -2,7 +2,7 @@ require 'formula' module Homebrew extend self def versions - raise "Please `brew install git` first" unless which_s "git" + raise "Please `brew install git` first" unless which "git" raise "Please `brew update' first" unless (HOMEBREW_REPOSITORY/".git").directory? raise FormulaUnspecifiedError if ARGV.named.empty? diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 3fcb4f2706..41c4fdeb3f 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -80,7 +80,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy safe_system '/usr/bin/tar', 'xf', @tarball_path chdir when :xz - raise "You must install XZutils: brew install xz" unless which_s "xz" + raise "You must install XZutils: brew install xz" unless which "xz" safe_system "xz -dc \"#{@tarball_path}\" | /usr/bin/tar xf -" chdir when :pkg @@ -322,7 +322,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy end def fetch - raise "You must install Git: brew install git" unless which_s "git" + raise "You must install Git: brew install git" unless which "git" ohai "Cloning #{@url}" @@ -455,7 +455,7 @@ class MercurialDownloadStrategy < AbstractDownloadStrategy def cached_location; @clone; end def fetch - raise "You must install Mercurial: brew install mercurial" unless which_s "hg" + raise "You must install Mercurial: brew install mercurial" unless which "hg" ohai "Cloning #{@url}" @@ -496,7 +496,7 @@ class BazaarDownloadStrategy < AbstractDownloadStrategy def cached_location; @clone; end def fetch - raise "You must install bazaar first" unless which_s "bzr" + raise "You must install bazaar first" unless which "bzr" ohai "Cloning #{@url}" unless @clone.exist? @@ -539,7 +539,7 @@ class FossilDownloadStrategy < AbstractDownloadStrategy def cached_location; @clone; end def fetch - raise "You must install fossil first" unless which_s "fossil" + raise "You must install fossil first" unless which "fossil" ohai "Cloning #{@url}" unless @clone.exist? diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 3ae8e11810..f5530c29f7 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 diff --git a/bin/brew b/bin/brew index eba5427248..ac713539c4 100755 --- a/bin/brew +++ b/bin/brew @@ -72,7 +72,7 @@ begin # Add example external commands to PATH before checking. ENV['PATH'] += ":#{HOMEBREW_REPOSITORY}/Library/Contributions/cmds" - if which_s "brew-#{cmd}" + if which "brew-#{cmd}" %w[CACHE CELLAR LIBRARY_PATH PREFIX REPOSITORY].each do |e| ENV["HOMEBREW_#{e}"] = Object.const_get "HOMEBREW_#{e}" end