mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
bugfix in CCUnix.escape_str
This commit is contained in:
parent
1fab81a832
commit
fc7f1a661a
2 changed files with 3 additions and 3 deletions
|
|
@ -55,7 +55,7 @@ let escape_str buf s =
|
||||||
Buffer.add_char buf '\'';
|
Buffer.add_char buf '\'';
|
||||||
String.iter
|
String.iter
|
||||||
(function
|
(function
|
||||||
| '\'' -> Buffer.add_string buf "''"
|
| '\'' -> Buffer.add_string buf "'\\''"
|
||||||
| c -> Buffer.add_char buf c
|
| c -> Buffer.add_char buf c
|
||||||
) s;
|
) s;
|
||||||
Buffer.add_char buf '\'';
|
Buffer.add_char buf '\'';
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ val escape_str : Buffer.t -> string -> unit
|
||||||
(*$T
|
(*$T
|
||||||
CCPrint.sprintf "%a" escape_str "foo" = "foo"
|
CCPrint.sprintf "%a" escape_str "foo" = "foo"
|
||||||
CCPrint.sprintf "%a" escape_str "foo bar" = "'foo bar'"
|
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 =
|
type call_result =
|
||||||
|
|
@ -69,7 +69,7 @@ val call : ?bufsize:int ->
|
||||||
|
|
||||||
(*$T
|
(*$T
|
||||||
(call ~stdin:(`Str "abc") "cat")#stdout = "abc"
|
(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"
|
(call "echo %s" "a'b'c")#stdout = "abc\n"
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue