diff --git a/ChangeLog.md b/ChangeLog.md index 2a3cc99a29..45b3cb503c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -18,6 +18,8 @@ Bug fixes: * Run the Cabal file checking in the `sdist` command more reliably by allowing the Cabal library to flatten the `GenericPackageDescription` itself. +* Script interpreter implicit file argumenst are now passed before other + arguments. See [#3658](https://github.com/commercialhaskell/stack/issues/3658). ## v1.6.1 diff --git a/src/main/Main.hs b/src/main/Main.hs index fd845982fb..e8192e806b 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -563,8 +563,12 @@ interpreterHandler currentDir args f = do progName <- getProgName iargs <- getInterpreterArgs path let parseCmdLine = commandLineHandler currentDir progName True - separator = if "--" `elem` iargs then [] else ["--"] - cmdArgs = stackArgs ++ iargs ++ separator ++ path : fileArgs + -- Implicit file arguments are put before other arguments that + -- occur after "--". See #3658 + cmdArgs = stackArgs ++ case break (== "--") iargs of + (beforeSep, []) -> beforeSep ++ ["--"] ++ [path] ++ fileArgs + (beforeSep, optSep : afterSep) -> + beforeSep ++ [optSep] ++ [path] ++ fileArgs ++ afterSep -- TODO show the command in verbose mode -- hPutStrLn stderr $ unwords $ -- ["Running", "[" ++ progName, unwords cmdArgs ++ "]"]