bugfix in CCUnix.escape_str

This commit is contained in:
Simon Cruanes 2015-05-07 15:07:33 +02:00
parent 1fab81a832
commit fc7f1a661a
2 changed files with 3 additions and 3 deletions

View file

@ -55,7 +55,7 @@ let escape_str buf s =
Buffer.add_char buf '\'';
String.iter
(function
| '\'' -> Buffer.add_string buf "''"
| '\'' -> Buffer.add_string buf "'\\''"
| c -> Buffer.add_char buf c
) s;
Buffer.add_char buf '\'';

View file

@ -43,7 +43,7 @@ val escape_str : Buffer.t -> string -> unit
(*$T
CCPrint.sprintf "%a" escape_str "foo" = "foo"
CCPrint.sprintf "%a" escape_str "foo bar" = "'foo bar'"
CCPrint.sprintf "%a" escape_str "fo'o b'ar" = "'fo''o b''ar'"
CCPrint.sprintf "%a" escape_str "fo'o b'ar" = "'fo'\\''o b'\\''ar'"
*)
type call_result =
@ -69,7 +69,7 @@ val call : ?bufsize:int ->
(*$T
(call ~stdin:(`Str "abc") "cat")#stdout = "abc"
(call "echo %a" escape_str "a'b'c")#stdout = "abc\n"
(call "echo %a" escape_str "a'b'c")#stdout = "a'b'c\n"
(call "echo %s" "a'b'c")#stdout = "abc\n"
*)