Ticket #2184 (new bug)
if findExecutable finds a file that matchs the argument, check if it is an executable
| Reported by: | iago | Owned by: | |
|---|---|---|---|
| Priority: | lowest | Milestone: | 7.6.2 |
| Component: | libraries/directory | Version: | 6.8.2 |
| Keywords: | findExecutable check executable | Cc: | |
| Operating System: | Linux | Architecture: | x86 |
| Type of failure: | Difficulty: | Unknown | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
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).
Change History
Note: See
TracTickets for help on using
tickets.
