forked from Remyjck/modular_decomposition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.ocamlinit
30 lines (26 loc) · 804 Bytes
/
.ocamlinit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#directory "+compiler-libs"
let try_finally ~always f =
match f () with
| x ->
always ();
x
| exception e ->
always ();
raise e
let use_output command =
let fn = Filename.temp_file "ocaml" "_toploop.ml" in
try_finally
~always:(fun () -> try Sys.remove fn with Sys_error _ -> ())
(fun () ->
match
Printf.ksprintf Sys.command "%s > %s" command (Filename.quote fn)
with
| 0 -> ignore (Toploop.use_file Format.std_formatter fn : bool)
| n -> Format.printf "Command exited with code %d.@." n)
let () =
let name = "use_output" in
if not (Hashtbl.mem Toploop.directive_table name) then
Hashtbl.add Toploop.directive_table name
(Toploop.Directive_string use_output)
;;
#remove_directory "+compiler-libs"