New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quoting in Unix.create_process #2939
Comments
Comment author: administrator
I beg to differ. The 3.08 code will produce that (correctly quoted) cmd.exe /C "ocamlc -pp "camlp4 arg" foo.ml (you can check this by replacing cmd.exe with the result of compiling The problem is that cmd.exe is broken and doesn't strip the " properly ocamlc -pp "camlp4 arg" foo.ml which ocamlc (correctly) parses as the following arguments: ocamlc instead of the expected ocamlc -pp "camlp4 arg" foo.ml which ocamlc would interpret as expected as ocamlc My only recommendation is not to use cmd.exe if at all possible. Best wishes,
#include <stdio.h> int main(int argc, char ** argv) |
Comment author: administrator The issue is in Windows' cmd.exe command-line parsing. ocaml does the right |
Comment author: administrator You are absolutely right. I missed this mail (hence my late reply), but Jason Xavier Leroy wrote:
|
Original bug ID: 2939
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Jason Hickey
Version: 3.08
OS: Win32
Submission from: adsl-67-120-175-90.dsl.lsan03.pacbell.net (67.120.175.90)
In 3.06, win32unix/unix.ml, the Unix.create_process function did not quote the
command arguments.
let create_process prog args fd1 fd2 fd3 =
win_create_process prog (String.concat " " (Array.to_list args)) None
fd1 fd2 fd3
In 3.08, it does:
let make_cmdline args =
let maybe_quote f =
if String.contains f ' ' || String.contains f '"'
then Filename.quote f
else f in
String.concat " " (List.map maybe_quote (Array.to_list args))
let create_process prog args fd1 fd2 fd3 =
win_create_process prog (make_cmdline args) None fd1 fd2 fd3
It seems like a reasonable idea, but it doesn't quite work. Consider the
following call:
let pid = Unix.create_process "cmd.exe"
[|"cmd.exe";
"/C";
"ocamlc -pp "camlp4 arg" foo.ml
|] fd0 fd1 fd2
The 3.08 code will produce this command line:
cmd.exe /C "ocamlc -pp "camlp4 arg" foo.ml"
This quoting inversion is a problem...
Jason
The text was updated successfully, but these errors were encountered: