import System.Cmd import System.IO import System.Environment import System.Process data Version = Version String String deriving (Show) main = do cs <- getArgs vs <- mapM getVersion cs print vs -- get at this from header.mk somehow. via args. yes. getVersion :: String -> IO Version getVersion s = Version s `fmap` (run $ case s of "ghc" -> "ghc-6.7.20070224 --version" "ghc-old" -> "ghc-6.6 --version" "ghc-asm" -> "ghc-6.6 --version" "ghci" -> "ghci --version" "hugs" -> "echo ':q' | hugs | sed -n 's/.*\\(Version:[^_]*\\)_*/\\1/p'" "nhc98" -> "nhc98 --version | sed '2d;s/.*: //'" "yhc" -> "yhc -v" "jhc-grin"-> "jhc -V" "jhc-ghc" -> "jhc -V" "hbc" -> "hbc -v 2>&1") run s = do (ih,oh,eh,pid) <- runInteractiveCommand s hClose ih so <- hGetContents oh se <- hGetContents eh map length [so,se] `seq` return () return (head . lines $ so ++ se)