if findExecutable finds a file that matchs the argument, check if it is an executable
When search finds a file that matchs with the fileName argument of findExecutable, it doesn't check if the file is an executable file.
do
path <- getEnv "PATH"
search (splitSearchPath path)
where
fileName = binary <.> exeExtension
search :: [FilePath] -> IO (Maybe FilePath)
search [] = return Nothing
search (d:ds) = do
let path = d </> fileName
b <- doesFileExist path
if b then return (Just path)
else search ds
findExecutable mustn't returns a file that it isn't an executable file, for example
(~/bin is in PATH variable)
$ touch ~/bin/foofile
$ ghci
$ :m System.Directory
$ findExecutable "foofile"
shows that findExecutable returns IO (Just "/home/iago/bin/foofile").
Altought is not a bug, could be good add a new funcion (findExecutables for example) to return all the executables in all the paths of PATH variable that matchs with a given filename (like which -a).
Trac metadata
Trac field | Value |
---|---|
Version | 6.8.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/directory |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |