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 ...@@ -91,19 +91,31 @@ findProgramOnSearchPath verbosity searchpath prog = do
Windows -> ["", "exe"] Windows -> ["", "exe"]
_ -> [""] _ -> [""]
tryPathElem ProgramSearchPathDefault = tryPathElem ProgramSearchPathDefault = do
findExecutable prog -- 'findExecutable' doesn't check that the path really refers to an
-- executable on Windows (at least with GHC < 7.8). See
-- https://ghc.haskell.org/trac/ghc/ticket/2184
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 [] = return Nothing
findFirstExe (f:fs) = do findFirstExe (f:fs) = do
isExe <- checkExe f
if isExe
then return (Just f)
else findFirstExe fs
checkExe f = do
exists <- doesFileExist f exists <- doesFileExist f
if exists if exists
then do perms <- getPermissions f then do perms <- getPermissions f
if executable perms return (executable perms)
then return (Just f) else return False
else findFirstExe fs
else findFirstExe fs
-- | Interpret a 'ProgramSearchPath' to construct a new @$PATH@ env var. -- | Interpret a 'ProgramSearchPath' to construct a new @$PATH@ env var.
-- Note that this is close but not perfect because on Windows the search -- 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