fix CCUnix.escape_str

This commit is contained in:
Simon Cruanes 2015-03-30 11:53:55 +02:00
parent 6fb26288ad
commit 1da809c596
2 changed files with 3 additions and 3 deletions

View file

@ -50,7 +50,7 @@ let rec iter_gen f g = match g() with
(* print a string, but escaped if required *) (* print a string, but escaped if required *)
let escape_str buf s = let escape_str buf s =
if str_exists s if str_exists s
(function ' ' | '"' | '\'' -> true | _ -> false) (function ' ' | '"' | '\'' | '\n' | '\t'-> true | _ -> false)
then ( then (
Buffer.add_char buf '\''; Buffer.add_char buf '\'';
String.iter String.iter
@ -79,7 +79,7 @@ let read_all ?(size=1024) ic =
with Exit -> with Exit ->
Bytes.sub_string !buf 0 !len Bytes.sub_string !buf 0 !len
type call_result = type call_result =
< stdout:string; < stdout:string;
stderr:string; stderr:string;
status:Unix.process_status; status:Unix.process_status;

View file

@ -45,7 +45,7 @@ val escape_str : Buffer.t -> string -> unit
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 =
< stdout:string; < stdout:string;
stderr:string; stderr:string;
status:Unix.process_status; status:Unix.process_status;