@ -526,16 +526,21 @@ let prepend_to_argv args =
args @ cl_args
args @ cl_args
(* * [prefix_before_rest ( prefix @ ["--" :: rest] ) ] is [prefix] where "--" is not in [prefix]. *)
(* * [prefix_before_rest ( prefix @ ["--" :: rest] ) ] is [prefix] where "--" is not in [prefix]. *)
let prefix_before_rest args =
let rev_ prefix_before_rest args =
let rec prefix_before_rest_ rev_keep = function
let rec rev_ prefix_before_rest_ rev_keep = function
| [] | " -- " :: _ -> IList . rev rev_keep
| [] | " -- " :: _ -> rev_keep
| keep :: args -> prefix_before_rest_ ( keep :: rev_keep ) args in
| keep :: args -> rev_ prefix_before_rest_ ( keep :: rev_keep ) args in
prefix_before_rest_ [] args
rev_ prefix_before_rest_ [] args
(* * environment variable use to pass arguments from parent to child processes *)
(* * environment variable use to pass arguments from parent to child processes *)
let args_env_var = " INFER_ARGS "
let args_env_var = " INFER_ARGS "
let extra_env_args = ref []
let extend_env_args args =
extra_env_args := List . rev_append args ! extra_env_args
let parse ? ( incomplete = false ) ? ( accept_unknown = false ) ? config_file current_exe exe_usage =
let parse ? ( incomplete = false ) ? ( accept_unknown = false ) ? config_file current_exe exe_usage =
let full_speclist = ref []
let full_speclist = ref []
in
in
@ -669,8 +674,14 @@ let parse ?(incomplete=false) ?(accept_unknown=false) ?config_file current_exe e
| Arg . Help usage_msg -> Pervasives . print_string usage_msg ; exit 0
| Arg . Help usage_msg -> Pervasives . print_string usage_msg ; exit 0
in
in
parse_loop () ;
parse_loop () ;
if not incomplete then
if not incomplete then (
Unix . putenv
(* reread args_to_parse instead of using all_args since mk_path_helper may have modified them *)
~ key : args_env_var
let prog_args =
~ data : ( encode_argv_to_env ( prefix_before_rest ( IList . tl ( Array . to_list ! args_to_parse ) ) ) ) ;
List . rev_append
( rev_prefix_before_rest ( Array . to_list ! args_to_parse ) )
( List . rev ! extra_env_args ) in
(* do not include program path in args passed via env var *)
let args = Option . value ( List . tl prog_args ) ~ default : [] in
Unix . putenv ~ key : args_env_var ~ data : ( encode_argv_to_env args )
) ;
curr_usage
curr_usage