module Main where import IO import System.Environment import System.Posix.Process ghc = ... -- Path to GHC. stripFirstLine = ... -- Path to the program below. -- #!/bin/sh -- grep -v '^#!' $2 > $3 main = do args <- getArgs if length args < 1 then hPutStr stderr usage else do let file:progArgs = args cmd = "System.Environment.withProgName " ++ show file ++ " $ System.Environment.withArgs " ++ show progArgs ++ " Main.main" ghcArgs = ["-F", "-pgmF", stripFirstLine, "-e", cmd, file] executeFile ghc False ghcArgs Nothing usage = "Usage: runghc [...]\n"