Last active
January 16, 2022 23:05
-
-
Save b0o/602744e0a6bf6400c2322eca34cc029a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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