Commit a7da5e01 authored by Moritz Angermann's avatar Moritz Angermann
Browse files

Take 2

parent f3a1eb72
......@@ -114,6 +114,7 @@ executable ghc-shake
, extra >= 1.4
, mtl >= 2.2
, shake >= 0.15
, split >= 0.2
, transformers >= 0.4
, unordered-containers >= 0.2
default-language: Haskell2010
......
......@@ -4,6 +4,7 @@ module Oracles.WindowsRoot (
) where
import Data.Char (isSpace)
import Data.List.Split (splitOn)
import Base
import Oracles.Config.Setting
......@@ -40,12 +41,13 @@ fixAbsolutePathOnWindows path = do
-- | Lookup a @command@ in @PATH@ environment.
lookupInPath :: FilePath -> Action FilePath
lookupInPath command
| command /= takeFileName command = return command
lookupInPath c
| c /= takeFileName c = return c
| otherwise = do
Stdout out <- quietly $ cmd ["which", command]
let path = dropWhileEnd isSpace out
return path
envPaths <- splitOn ":" <$> getEnvWithDefault "" "PATH"
let candidates = map (-/- c) envPaths in
-- this will crash if we do not find any valid candidate.
head <$> filterM doesFileExist candidates
-- Oracle for windowsRoot. This operation requires caching as looking up
-- the root is slow (at least the current implementation).
......
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