[project @ 2004-08-13 13:29:00 by simonmar]
[ghc-base.git] / System / Cmd.hs
index b1492e0..5838f85 100644 (file)
 module System.Cmd
     ( system,        -- :: String -> IO ExitCode
 #ifdef __GLASGOW_HASKELL__
-      rawSystem,     -- :: String -> IO ExitCode
+      rawSystem,     -- :: FilePath -> [String] -> IO ExitCode
 #endif
     ) where
 
 import Prelude
 
 #ifdef __GLASGOW_HASKELL__
-import System.Exit
+import Foreign
 import Foreign.C
+import System.Exit
 import GHC.IOBase
+#include "ghcconfig.h"
 #endif
 
 #ifdef __HUGS__
@@ -70,20 +72,10 @@ system cmd =
 
 foreign import ccall unsafe "systemCmd" primSystem :: CString -> IO Int
 
-{- | 
-The same as 'system', but bypasses the shell.  Will behave more portably between
-systems, because there is no interpretation of shell metasyntax.
--}
-
-rawSystem :: String -> IO ExitCode
-rawSystem "" = ioException (IOError Nothing InvalidArgument "rawSystem" "null command" Nothing)
-rawSystem cmd =
-  withCString cmd $ \s -> do
-    status <- throwErrnoIfMinus1 "rawSystem" (primRawSystem s)
-    case status of
-        0  -> return ExitSuccess
-        n  -> return (ExitFailure n)
+-- ---------------------------------------------------------------------------
+-- rawSystem
 
-foreign import ccall unsafe "rawSystemCmd" primRawSystem :: CString -> IO Int
+-- rawSystem is in a separate file, so we can #include it various places.
+#include "RawSystem.hs-inc"
 
 #endif  /* __GLASGOW_HASKELL__ */