Permalink
Browse files

Added forgotten Util.hs for 'repository location discovery' patch

  • Loading branch information...
trofi committed Mar 15, 2009
1 parent 830d9bb commit 3d054ded7e81651d4ad7b5d9320bb2785f0abefd
Showing with 26 additions and 0 deletions.
  1. +26 −0 Util.hs
View
26 Util.hs
@@ -0,0 +1,26 @@
+{-|
+ Author : Sergei Trofimovich <slyfox@inbox.ru>
+ Stability : experimental
+ Portability : haskell98
+
+ Ungrouped utilitary stuff lays here until someone finds better place for it :]
+-}
+
+module Util
+ ( run_cmd -- :: String -> IO (Maybe String)
+ ) where
+
+import System.IO
+import System.Process
+import System.Exit
+
+-- 'run_cmd' executes command and returns it's standard output
+-- as 'String'.
+
+run_cmd :: String -> IO (Maybe String)
+run_cmd cmd = do (_hI, hO, _hE, hProcess) <- runInteractiveCommand cmd
+ output <- hGetContents hO
+ _exitCode <- waitForProcess hProcess
+ return $ if (output == "")
+ then Nothing
+ else Just output

0 comments on commit 3d054de

Please sign in to comment.