KAc*_*ion 0 windows shell portability haskell path
是否可以检查给定的字符串是否代表$ PATH(%path%)中的可执行文件?它必须可移植到Windows.只是调用它并查看返回状态的想法不适用,因为非零可能意味着程序错误或程序未找到.好吧,在代码中,我想要关注
possibleCompilers = ["gcc", "icc", "foo", "bar.exe"]
presentCompiler :: IO String
Run Code Online (Sandbox Code Playgroud)
这项任务应该可以使用System.Directory.findExecutable.
possibleCompiler :: IO (Maybe String)
possibleCompiler = check possibleCompilers
where
check [] = return Nothing
check (c:cs) = do
mbc <- findExecutable c
case mbc of
Just _ -> return mbc
Nothing -> check cs
Run Code Online (Sandbox Code Playgroud)
我改变了类型IO (Maybe String),因为可能没有找到任何候选人.
| 归档时间: |
|
| 查看次数: |
81 次 |
| 最近记录: |