diff --git a/src/unix/CCUnix.ml b/src/unix/CCUnix.ml index b613a855..5743d636 100644 --- a/src/unix/CCUnix.ml +++ b/src/unix/CCUnix.ml @@ -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 '\''; diff --git a/src/unix/CCUnix.mli b/src/unix/CCUnix.mli index e60b13df..1af80d9d 100644 --- a/src/unix/CCUnix.mli +++ b/src/unix/CCUnix.mli @@ -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" *)