diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index 32415dff4..ae302ef11 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -193,10 +193,14 @@ let write_json_to_file destfile json = with_file_out destfile ~f:(fun oc -> Yojson.Basic.pretty_to_channel oc json) -let consume_in chan_in = - try while true do In_channel.input_line_exn chan_in |> ignore done with End_of_file -> () +let with_channel_in ~f chan_in = + try while true do f @@ In_channel.input_line_exn chan_in done with End_of_file -> () +let consume_in chan_in = with_channel_in ~f:ignore chan_in + +let echo_in chan_in = with_channel_in ~f:print_endline chan_in + let with_process_in command read = let chan = Unix.open_process_in command in let f () = read chan in diff --git a/infer/src/base/Utils.mli b/infer/src/base/Utils.mli index 93e5d2e38..acf3892c7 100644 --- a/infer/src/base/Utils.mli +++ b/infer/src/base/Utils.mli @@ -59,6 +59,10 @@ val with_file_out : string -> f:(Out_channel.t -> 'a) -> 'a val write_json_to_file : string -> Yojson.Basic.json -> unit val consume_in : In_channel.t -> unit +(** consume and ignore all the lines from the channel until End_of_file is reached *) + +val echo_in : In_channel.t -> unit +(** echo the lines we get to stdout until End_of_file is reached *) val with_process_in : string -> (In_channel.t -> 'a) -> 'a * Unix.Exit_or_signal.t diff --git a/infer/src/clang/Capture.ml b/infer/src/clang/Capture.ml index 3482ef39f..8697e2961 100644 --- a/infer/src/clang/Capture.ml +++ b/infer/src/clang/Capture.ml @@ -179,4 +179,4 @@ let capture clang_cmd = absolute paths. *) let command_to_run = ClangCommand.command_to_run clang_cmd in L.(debug Capture Quiet) "Running non-cc command without capture: %s@\n" command_to_run ; - run_clang command_to_run Utils.consume_in + run_clang command_to_run Utils.echo_in