Skip to content

Commit

Permalink
Put file arguments first when stack is run as script interpreter #3658
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Dec 18, 2017
1 parent fbae9f3 commit c8375e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions src/main/Main.hs
Expand Up @@ -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 ++ "]"]
Expand Down

0 comments on commit c8375e7

Please sign in to comment.