|
@@ -42,10 +42,17 @@ let what_next ~tmp ~cmd_list =
|
|
|
let tmp_json = Yojson.Basic.from_file tmp in
|
|
|
let open Yojson.Basic.Util in
|
|
|
let num_next = tmp_json |> member "num" |> to_int in (* Number of the next cmd to run *)
|
|
|
- let cmd_to_exec = List.nth cmd_list num_next in
|
|
|
- match cmd_to_exec with
|
|
|
- | None -> ""
|
|
|
- | Some x -> x
|
|
|
+ (*Verify that the number is not out of the list *)
|
|
|
+ if (List.length cmd_list) < num_next
|
|
|
+ then
|
|
|
+ ""
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ let cmd_to_exec = List.nth cmd_list num_next in
|
|
|
+ match cmd_to_exec with
|
|
|
+ | None -> ""
|
|
|
+ | Some x -> x
|
|
|
+ end
|
|
|
;;
|
|
|
|
|
|
(* Log when a program has been launched in a file in /tmp
|