Skip to content

Instantly share code, notes, and snippets.

@b0o
Last active January 16, 2022 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b0o/602744e0a6bf6400c2322eca34cc029a to your computer and use it in GitHub Desktop.
Save b0o/602744e0a6bf6400c2322eca34cc029a to your computer and use it in GitHub Desktop.
let stringOfChannel ch =
let ok = ref false in
let result = ref "" in
let _ =
try
while true do
result := !result ^ "\n" ^ input_line ch
done
with End_of_file -> (
match Unix.close_process_in ch with
| WEXITED 0 -> ok := true
| _ -> ok := false)
in
match !ok with true -> Some !result | false -> None
let doStuff cmd ~path =
let in_channel =
Unix.open_process_args_in cmd [|"--stuff"; "yah"; "--lol"; path|]
in
match stringOfChannel in_channel with
| Some res -> res
| None -> "TODO"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment