
#8601: runghc from standard input and --ghc-args ------------------------------------+------------------------------------- Reporter: wuzzeb | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- I am trying to use runghc with a cabal sandbox, and it works when the haskell code is in a file like follows: {{{ runghc -- -package-db --ghc-arg=.cabal-sandbox/i386-linux- ghc-7.6.3-packages.conf.d somefile.hs }}} But if I try and load the script from standard input (actually I am trying to run a GHC script from a bash script using "runghc << EOF" but it is easier to see if you just run from the console) {{{ runghc -- -package-db --ghc-arg=.cabal-sandbox/i386-linux- ghc-7.6.3-packages.conf.d < somefile.hs }}} you get an error {{{ .cabal-sandbox/i386-linux-ghc-7.6.3-packages.conf.d/:1:57: Not in scope: `main' Perhaps you meant `min' (imported from Prelude) }}} Looking at the utils/runghc/runghc.hs source file, what happens is inside the doIt function. The first thing the doIt function does is call getGhcArgs which strips the --ghc-args. Then it checks the args and sees there is no file, so falls into the case where it reads standard input, creates a temp file, and then recalls doIt. Here is the problem, because the "--ghc-arg" string has already been stripped so the second call to doIt is where the error occurs. With that, I can actually get it to work with the following :) {{{ runghc -- -package-db --ghc-arg=--ghc-arg=.cabal-sandbox/i386-linux- ghc-7.6.3-packages.conf.d < somefile.hs }}} By passing --ghc-arg= twice, it is stripped once the first time doIt is called and once the second time and GHC gets the correct args :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8601 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler