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 getVersion :: String -> IO Version getVersion s = Version s `fmap` (run $ case s of "ghc" -> "ghc-6.6 --version" "ghc-old" -> "ghc-6.4.2 --version" "ghci" -> "ghci --version" "hugs" -> "echo ':q' | hugs | sed -n 's/.*\\(Version:[^_]*\\)_*/\\1/p'" "nhc98" -> "nhc98 --version | sed '2d;s/.*: //'" "yhc" -> "yhc -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)