Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1042 from fdopen/create_process_quoting
Fix Unix.create_process command-line escaping under Windows
- Loading branch information
1 parent
e419959
commit 06a49a0
Showing
7 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <stdio.h> | ||
|
||
int main (int argc, char *argv[]) | ||
{ | ||
int i; | ||
for (i = 1; i < argc; i ++) { | ||
printf ("%s\n", argv[i]); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
open Unix | ||
|
||
let prog_name = "cmdline_prog.exe" | ||
|
||
let run args = | ||
let out, inp = pipe () in | ||
let in_chan = in_channel_of_descr out in | ||
set_binary_mode_in in_chan false; | ||
let pid = create_process ("./" ^ prog_name) (Array.of_list (prog_name :: args)) Unix.stdin inp Unix.stderr in | ||
List.iter (fun arg -> | ||
let s = input_line in_chan in | ||
Printf.printf "%S -> %S [%s]\n" arg s (if s = arg then "OK" else "FAIL") | ||
) args; | ||
close_in in_chan; | ||
let _, exit = waitpid [] pid in | ||
assert (exit = WEXITED 0) | ||
|
||
let () = | ||
List.iter run | ||
[ | ||
[""; ""; "\t \011"]; | ||
["a"; "b"; "c.txt@!"]; | ||
["\""]; | ||
[" "; " a "; " \" \\\" "]; | ||
[" \\ \\ \\\\\\"]; | ||
[" \"hola \""]; | ||
["a\tb"]; | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"" -> "" [OK] | ||
"" -> "" [OK] | ||
"\t \011" -> "\t \011" [OK] | ||
"a" -> "a" [OK] | ||
"b" -> "b" [OK] | ||
"c.txt@!" -> "c.txt@!" [OK] | ||
"\"" -> "\"" [OK] | ||
" " -> " " [OK] | ||
" a " -> " a " [OK] | ||
" \" \\\" " -> " \" \\\" " [OK] | ||
" \\ \\ \\\\\\" -> " \\ \\ \\\\\\" [OK] | ||
" \"hola \"" -> " \"hola \"" [OK] | ||
"a\tb" -> "a\tb" [OK] |