Browse thread
Sys.command and quotes
-
Matthieu Dubuget
- Francois Pottier
- Olivier Andrieu
- Sylvain Le Gall
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-05-05 (09:44) |
From: | Olivier Andrieu <oandrieu@n...> |
Subject: | Re: [Caml-list] Sys.command and quotes |
On Tue, May 5, 2009 at 10:58, Matthieu Dubuget <matthieu.dubuget@gmail.com> wrote: > Hello, > > I have a problem with mingw version of ocaml (compiled by hand, or with > godi). > > 1- Is the following reproducible? > > 2- If yes, do you consider this as a bug? > > It seems that in "Sys.command s", if the first and the last characters of s > are '"', they are elided? that's probably just the Windows command interpreter behaviour. Sys.command calls the C library system() function which ends up calling CMD.EXE. This one has an utterly byzantine behavior concerning quotations marks. cf. http://technet.microsoft.com/en-us/library/bb490880.aspx « Processing quotation marks If you specify /c or /k, cmd processes the remainder of string and quotation marks are preserved only if all of the following conditions are met: * You do not use /s. * You use exactly one set of quotation marks. * You do not use any special characters within the quotation marks (for example: &<>( ) @ ^ |). * You use one or more white-space characters within the quotation marks. * The string within quotation marks is the name of an executable file. If the previous conditions are not met, string is processed by examining the first character to verify whether or not it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved. » IIRC a sort of workaround is to always add extra " in your command line: go ["\"" ; .... ; "\""] good luck -- Olivier