#2184: if findExecutable finds a file that matchs the argument don't check if it
is an executable
------------------------------------------------+---------------------------
Reporter: iago | Owner:
Type: bug | Status: new
Priority: normal | Component:
libraries/directory
Version: 6.8.2 | Severity: normal
Keywords: findExecutable check executable | Testcase:
Architecture: x86 | Os: Linux
------------------------------------------------+---------------------------
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).
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2184>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs