[project @ 2004-01-28 10:04:25 by simonpj]
authorsimonpj <unknown>
Wed, 28 Jan 2004 10:04:25 +0000 (10:04 +0000)
committersimonpj <unknown>
Wed, 28 Jan 2004 10:04:25 +0000 (10:04 +0000)
---------------------------------------
    Fix the WinME/98/95 double-backslash bug
  ---------------------------------------

Merge to stable branch, at least
once we are sure it's right

Backslashes should not be escaped in command-line arguments for rawSystem,
on Win32.  This only actually causes failures on WinME/98/95, and we can't
test that since we don't have it.  But this fix seems right regardless.

There are extensive new comments in libraries/base/System/Cmd.hs which
describe the issues.

ghc/compiler/main/SysTools.lhs

index 0320cff..7d933c1 100644 (file)
@@ -764,10 +764,19 @@ traceCmd phase_name cmd_line action
 
 -- -----------------------------------------------------------------------------
 -- rawSystem: run an external command
+--
+-- In GHC 6.2.1 there's a correct implementation of rawSystem in the
+-- library System.Cmd.  If we are compiling with an earlier version of
+-- GHC than this, we'd better have a copy of the correct implementation
+-- right here.
+
+-- If you ever alter this code, you must alter 
+--     libraries/base/System/Cmd.hs
+-- at the same time!  There are also exensive comments in System.Cmd
+-- thare are not repeated here -- go look!
 
-#if __GLASGOW_HASKELL__ < 601
 
--- This code is copied from System.Cmd on GHC 6.1.
+#if __GLASGOW_HASKELL__ < 621
 
 rawSystem :: FilePath -> [String] -> IO ExitCode
 
@@ -810,7 +819,6 @@ translate :: String -> String
 translate str@('"':_) = str -- already escaped.
 translate str = '"' : foldr escape "\"" str
   where escape '"'  str = '\\' : '"'  : str
-       escape '\\' str = '\\' : '\\' : str
        escape c    str = c : str
 
 foreign import ccall "rawSystem" unsafe