From 23fbe23426effa91c06fa3c2bcaa5f7c4f828dca Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 9 Aug 2013 20:39:17 -0500 Subject: [PATCH] Allow specifying a custom PATH for which method Closes Homebrew/homebrew#21794. --- Library/Homebrew/requirements/python_dependency.rb | 12 +++--------- Library/Homebrew/utils.rb | 4 ++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/requirements/python_dependency.rb b/Library/Homebrew/requirements/python_dependency.rb index e84645da43..21d3c8af26 100644 --- a/Library/Homebrew/requirements/python_dependency.rb +++ b/Library/Homebrew/requirements/python_dependency.rb @@ -121,15 +121,9 @@ class PythonInstalled < Requirement # Note, we don't support homebrew/versions/pythonXX.rb, though. Formula.factory(@name).opt_prefix/"bin/python#{@min_version.major}" else - begin - # Using the ORIGINAL_PATHS here because in superenv, the user - # installed external Python is not visible otherwise. - tmp_PATH = ENV['PATH'] - ENV['PATH'] = ORIGINAL_PATHS.join(':') - which(@name) - ensure - ENV['PATH'] = tmp_PATH - end + # Using the ORIGINAL_PATHS here because in superenv, the user + # installed external Python is not visible otherwise. + which(@name, ORIGINAL_PATHS.join(':')) end end end diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 8183549931..2224e4ed00 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -166,8 +166,8 @@ def puts_columns items, star_items=[] end end -def which cmd - dir = ENV['PATH'].split(':').find {|p| File.executable? File.join(p, cmd)} +def which cmd, path=ENV['PATH'] + dir = path.split(':').find {|p| File.executable? File.join(p, cmd)} Pathname.new(File.join(dir, cmd)) unless dir.nil? end