gregwebs / Shelly.hs

Haskell shell scripting
BSD 3-Clause "New" or "Revised" License
418 stars 88 forks source link

Shelly automatically appends ".exe" on command names #165

Open eric-corumdigital opened 6 years ago

eric-corumdigital commented 6 years ago

A snippet from the source code:

-- | Get a full path to an executable by looking at the @PATH@ environement
-- variable. Windows normally looks in additional places besides the
-- @PATH@: this does not duplicate that behavior.
whichEith :: FilePath -> Sh (Either String FilePath)
whichEith originalFp = whichFull
#if defined(mingw32_HOST_OS)
    $ case extension originalFp of
        Nothing -> originalFp <.> "exe"
        Just _ -> originalFp
#else
    originalFp
#endif

I am guessing this is an attempt to work somewhat like how Windows usually looks for executables. I do not see any non-breaking way to change how whichEith works, but here are two ideas:

  1. Do nothing to the file path, regardless of OS. This requires Shelly users to append .exe themselves.
  2. First try and find the file without the .exe suffix. If that fails, try and find the file with the .exe suffix. Maybe this causes the wrong executable to be used.

I would happily send in a PR for either of these but because it is a breaking change either way I assume it wants to be discussed.

Related to https://github.com/yesodweb/Shelly.hs/issues/112

gregwebs commented 6 years ago

I like option 2 as a solution.

gregwebs commented 6 years ago

The third option, which would not be breaking would be to look for the .exe first, and if not found look without the .exe