Commit 6b06b6ca authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Work around 'findExecutable' being buggy on Windows.

parent 2e26b84c
......@@ -91,19 +91,31 @@ findProgramOnSearchPath verbosity searchpath prog = do
Windows -> ["", "exe"]
_ -> [""]
tryPathElem ProgramSearchPathDefault =
findExecutable prog
tryPathElem ProgramSearchPathDefault = do
-- 'findExecutable' doesn't check that the path really refers to an
-- executable on Windows (at least with GHC < 7.8). See
mExe <- findExecutable prog
case mExe of
Just exe -> do isExe <- checkExe exe
if isExe
then return mExe
else return Nothing
_ -> return mExe
findFirstExe [] = return Nothing
findFirstExe (f:fs) = do
isExe <- checkExe f
if isExe
then return (Just f)
else findFirstExe fs
checkExe f = do
exists <- doesFileExist f
if exists
then do perms <- getPermissions f
if executable perms
then return (Just f)
else findFirstExe fs
else findFirstExe fs
return (executable perms)
else return False
-- | Interpret a 'ProgramSearchPath' to construct a new @$PATH@ env var.
-- Note that this is close but not perfect because on Windows the search
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment