Problem with ghc on Windows ME
rjblack at microsoft.com
Thu Jan 29 07:32:34 EST 2004
If you want to know what it does just refer to the source; it is and
always has been distributed with Visual C.
See C:\Program Files\Microsoft Visual Studio .NET
From: Simon Peyton-Jones
Sent: 29 January 2004 15:18
To: Simon Marlow; 'Claus Reinke'; 'glasgow-haskell-users at haskell.org'
Cc: Richard Black; Simon Peyton-Jones
Subject: RE: Problem with ghc on Windows ME
Well found! Still, I found I could not understand the rules.
But I think the story this
Convert \" to \\\"
otherwise convert " to \"
otherwise do no conversion
I think it's probably easiest to express this directly:
translate :: String -> String
translate str = '"' : go str
where go ('\\' : '"' : s) = '\\' : '\\' : '\\' : '"' : go s
go ('"' : s) = '\\' : '"' : go s
go (c:s) = c : go s
go  = ['"']
| -----Original Message-----
| From: Simon Marlow
| Sent: 29 January 2004 14:53
| To: Claus Reinke; Simon Peyton-Jones;
glasgow-haskell-users at haskell.org
| Subject: RE: Problem with ghc on Windows ME
| After Googling around a bit, I found this description of exactly how
Windows interprets command lines
| in the C runtime:
| As you can see, the rules are indeed very strange, but they are
invertible. I think this code should do
| the trick:
| translate :: String -> String
| translate str = '"' : snd (foldr escape (True,"\"") str)
| where escape '"' (_, str) = (True, '\\' : '"' : str)
| escape '\\' (True, str) = (True, '\\' : '\\' : str)
| escape '\\' (False, str) = (False, '\\' : str)
| escape c (_, str) = (False, c : str)
| > -----Original Message-----
| > From: glasgow-haskell-users-bounces at haskell.org
| > [mailto:glasgow-haskell-users-bounces at haskell.org] On Behalf
| > Of Simon Marlow
| > Sent: 29 January 2004 11:31
| > To: Claus Reinke; Simon Peyton-Jones;
| > glasgow-haskell-users at haskell.org
| > Subject: RE: Problem with ghc on Windows ME
| > > So does that mean functionality has been lost in the move from
| > > ghc-6.0.1?
| > No, the behaviour is improved in 6.2 because we're now
| > careful to escape
| > quotes before passing the command-line to the operating system.
| > I think confusion has arisen because Simon pointed out that there's
| > way, on Windows, to pass this sequence of characters as an
| > argument to a
| > command:
| > \"
| > This is not entirely true, I just discovered that the
| > sequence \\\" will
| > turn into \". But in general, the sequence \\ does not turn into \.
| > Windows' command-line quoting rules are highly mysterious, to say
| > least.
| > So the patch I posted is not complete. It looks like rawSystem
| > additionally translate \" as \\\".
| > > Because that (on win98) happily accepts such useful
| > > contraptions as
| > >
| > > System.Cmd.rawSystem "\"c:\\silly
| > > space\\Vim\\vim62\\gvim.exe\" --servername GVIM --remote-send
| > > \":echo \\\"hi \\\\\\\" there\\\"<cr>\"" >>= print
| > The idea is that you should pass to rawSystem *exactly* the
| > command and
| > arguments you want to run, with no quoting except that required by
| > Haskell lexical syntax. You'll notice that rawSystem now takes the
| > command and list of arguments separately in 6.2. The
| > implementation of
| > rawSystem will attempt to compensate for the internal translation
| > Windows does on the command-line; on Unix no translation is
| > So clients of rawSystem should be more portable, because they
| > don't have
| > to know about quoting that happens under the hood.
| > Your example will probably work once it's reformulated for
| > 6.2's version
| > of rawSystem, and once we fix rawSystem in light of the \\\" hack I
| > discovered above.
| > Cheers,
| > Simon
| > _______________________________________________
| > Glasgow-haskell-users mailing list
| > Glasgow-haskell-users at haskell.org
| > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
More information about the Glasgow-haskell-users