utils.rb:which: bug fix

Closes Homebrew/homebrew#27524.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
This commit is contained in:
kynnjo 2014-03-13 17:20:36 -04:00 committed by Adam Vandenberg
parent c84c8b1d0e
commit 5f8e78150e

View File

@ -170,7 +170,10 @@ def puts_columns items, star_items=[]
end
def which cmd, path=ENV['PATH']
dir = path.split(File::PATH_SEPARATOR).find {|p| File.executable? File.join(p, cmd)}
dir = path.split(File::PATH_SEPARATOR).find {|p|
pcmd = File.join(p, cmd)
File.executable?(pcmd) && !File.directory?(pcmd)
}
Pathname.new(File.join(dir, cmd)) unless dir.nil?
end