doit :: String -> [FilePath] -> IO ()
doit function files
 = do (hIn, hOut, hErr, ph) <- runInteractiveProcess
                                   "grep" ("-h" : function : files)
                                   Nothing Nothing
      hClose hIn
      strOut <- hGetContents hOut
      strErr <- hGetContents hErr
      forkIO $ do evaluate (length strOut)
                  return ()
      forkIO $ do evaluate (length strErr)
                  return ()
      ec <- waitForProcess ph
      case (ec, strErr) of
          (ExitSuccess, "") ->
              check function strOut
          _ ->
              error "grep failed"
doit :: String -> [FilePath] -> IO ()
doit function files
 = do (hIn, hOut, hErr, ph) <- runInteractiveProcess
                                   "grep" ("-h" : function : files)
                                   Nothing Nothing
      hClose hIn
      strOut <- hGetContents hOut
      strErr <- hGetContents hErr
      forkIO $ do evaluate (length strOut)
                  return ()
      forkIO $ do evaluate (length strErr)
                  return ()
      ec <- waitForProcess ph
      case (ec, strErr) of
          (ExitSuccess, "") ->
              check function strOut
          _ ->
              error "grep failed"
doit function files
 = do (hIn, hOut, hErr, ph) <- runInteractiveProcess
                                   "grep" ("-h" : function : files)
                                   Nothing Nothing
      hClose hIn
      strOut <- hGetContents hOut
      strErr <- hGetContents hErr
      forkIO $ do evaluate (length strOut)
                  return ()
      forkIO $ do evaluate (length strErr)
                  return ()
      ec <- waitForProcess ph
      case (ec, strErr) of
          (ExitSuccess, "") ->
              check function strOut
          _ ->
              error "grep failed"