Commit d43d14f7 authored by simonmar's avatar simonmar

[project @ 2005-04-21 10:06:17 by simonmar]

Allow args to be passed to GHC from runghc

  syntax: runghc [-f GHCPATH] [GHC-ARGS] FILE ARG...
parent ff8ad7fb
......@@ -34,22 +34,30 @@ import Compat.Directory ( findExecutable )
main = do
args <- getArgs
case args of
('-':'f' : ghc) : filename : args -> do
doIt (dropWhile isSpace ghc) filename args
filename : args -> do
('-':'f' : ghc) : args -> do
doIt (dropWhile isSpace ghc) args
args -> do
mb_ghc <- findExecutable "ghc"
case mb_ghc of
Nothing -> dieProg ("cannot find ghc")
Just ghc -> doIt ghc filename args
_other -> do
dieProg "syntax: runghc [-f GHCPATH] FILE ARG..."
Just ghc -> doIt ghc args
doIt ghc filename args = do
res <- rawSystem ghc ["-ignore-dot-ghci",
"-e","System.Environment.withProgName "++show filename++" (System.Environment.withArgs ["
++ concat (intersperse "," (map show args))
++ "] Main.main)", filename]
exitWith res
doIt ghc args = do
let
(ghc_args, rest) = break notArg args
--
case rest of
[] -> dieProg "syntax: runghc [-f GHCPATH] [GHC-ARGS] FILE ARG..."
filename : prog_args -> do
res <- rawSystem ghc (
"-ignore-dot-ghci" : ghc_args ++
[ "-e","System.Environment.withProgName "++show filename++" (System.Environment.withArgs ["
++ concat (intersperse "," (map show prog_args))
++ "] Main.main)", filename])
exitWith res
notArg ('-':_) = False
notArg _ = True
dieProg :: String -> IO a
dieProg msg = do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment