From 5f8e78150e47f2f68c5239a644198968398eb9e3 Mon Sep 17 00:00:00 2001 From: kynnjo Date: Thu, 13 Mar 2014 17:20:36 -0400 Subject: [PATCH] utils.rb:which: bug fix Closes Homebrew/homebrew#27524. Signed-off-by: Adam Vandenberg --- Library/Homebrew/utils.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 519b2869af..8c73296525 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -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