[project @ 2005-11-11 12:01:58 by simonmar]
[haskell-directory.git] / System / Cmd.hs
index 9777bf1..2d8635f 100644 (file)
@@ -115,21 +115,26 @@ rawSystem cmd args = do
   return r
 #endif
 
-#else /* ! __GLASGOW_HASKELL__ */
+#elif !mingw32_HOST_OS
 -- crude fallback implementation: could do much better than this under Unix
 rawSystem cmd args = system (unwords (map translate (cmd:args)))
 
 translate :: String -> String
-#if defined(mingw32_HOST_OS)
+translate str = '\'' : foldr escape "'" str
+  where        escape '\'' = showString "'\\''"
+       escape c    = showChar c
+#else /* mingw32_HOST_OS &&  ! __GLASGOW_HASKELL__ */
+# if __HUGS__
+rawSystem cmd args = system (unwords (cmd : map translate args))
+# else
+rawSystem cmd args = system (unwords (map translate (cmd:args)))
+#endif
+
 -- copied from System.Process (qv)
+translate :: String -> String
 translate str = '"' : snd (foldr escape (True,"\"") str)
   where        escape '"'  (b,     str) = (True,  '\\' : '"'  : str)
        escape '\\' (True,  str) = (True,  '\\' : '\\' : str)
        escape '\\' (False, str) = (False, '\\' : str)
        escape c    (b,     str) = (False, c : str)
-#else /* ! mingw32_HOST_OS */
-translate str = '\'' : foldr escape "'" str
-  where        escape '\'' cs = '\'' : '\\' : '\'' : '\'' : cs
-       escape c    cs = c : cs
-#endif /* ! mingw32_HOST_OS */
-#endif /* ! __GLASGOW_HASKELL__ */
+#endif