Ticket #2184 (new bug)

Opened 5 years ago

Last modified 8 months ago

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

Changed 5 years ago by igloo

  • difficulty set to Unknown
  • summary changed from if findExecutable finds a file that matchs the argument don't check if it is an executable to if findExecutable finds a file that matchs the argument, check if it is an executable
  • milestone set to 6.8.3

Thanks for the report; we should be able to fix this for 6.8.3.

For your proposed findExecutables addition, please follow the  library submissions procedure.

Changed 5 years ago by igloo

  • milestone changed from 6.8.3 to 6.10 branch

Hmm, the system function that we use on Windows returns the first path, regardless of whether or not it is executable. I think we should punt on this for now, and revisit it or 6.10.

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 2 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 20 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 16 months ago by igloo

  • priority changed from low to lowest
  • milestone changed from 7.4.1 to 7.6.1

Changed 8 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2
Note: See TracTickets for help on using tickets.