[lit] Fix bug where ``lit.util.which()`` would return a directory
[oota-llvm.git] / utils / lit / lit / util.py
index a4233bac7aa5bc43a1e777dcd8495297da335b31..224509ab840b610bf773b4f85eca8911f6f97720 100644 (file)
@@ -94,7 +94,7 @@ def which(command, paths = None):
     for path in paths.split(os.pathsep):
         for ext in pathext:
             p = os.path.join(path, command + ext)
-            if os.path.exists(p):
+            if os.path.exists(p) and not os.path.isdir(p):
                 return p
 
     return None