diff options
-rw-r--r-- | toplevel/toploop.ml | 15 | ||||
-rw-r--r-- | toplevel/topmain.ml | 2 | ||||
-rw-r--r-- | utils/clflags.ml | 1 |
3 files changed, 13 insertions, 5 deletions
diff --git a/toplevel/toploop.ml b/toplevel/toploop.ml index 6757abf34..a8bb58297 100644 --- a/toplevel/toploop.ml +++ b/toplevel/toploop.ml @@ -368,11 +368,16 @@ let _ = crc_intfs let load_ocamlinit ppf = - let home_init = - try Filename.concat (Sys.getenv "HOME") ".ocamlinit" - with Not_found -> ".ocamlinit" in - if Sys.file_exists ".ocamlinit" then ignore(use_silently ppf ".ocamlinit") - else if Sys.file_exists home_init then ignore(use_silently ppf home_init) + match !Clflags.init_file with + | Some f -> if Sys.file_exists f then ignore (use_silently ppf f) + else fprintf ppf "Init file not found: \"%s\".@." f + | None -> + if Sys.file_exists ".ocamlinit" then ignore (use_silently ppf ".ocamlinit") + else try + let home_init = Filename.concat (Sys.getenv "HOME") ".ocamlinit" in + if Sys.file_exists home_init then ignore (use_silently ppf home_init) + with Not_found -> () +;; let set_paths () = (* Add whatever -I options have been specified on the command line, diff --git a/toplevel/topmain.ml b/toplevel/topmain.ml index fadfb57c5..012951675 100644 --- a/toplevel/topmain.ml +++ b/toplevel/topmain.ml @@ -56,6 +56,8 @@ let main () = let dir = Misc.expand_directory Config.standard_library dir in include_dirs := dir :: !include_dirs), "<dir> Add <dir> to the list of include directories"; + "-init", Arg.String (fun s -> init_file := Some s), + "<file> Load <file> instead of default init file"; "-labels", Arg.Clear classic, " Labels commute (default)"; "-noassert", Arg.Set noassert, " Do not compile assertion checks"; "-nolabels", Arg.Set classic, " Ignore labels and do not commute"; diff --git a/utils/clflags.ml b/utils/clflags.ml index 4d7987565..e51e430c9 100644 --- a/utils/clflags.ml +++ b/utils/clflags.ml @@ -39,6 +39,7 @@ and use_vmthreads = ref false (* -vmthread *) and noassert = ref false (* -noassert *) and verbose = ref false (* -verbose *) and noprompt = ref false (* -noprompt *) +and init_file = ref (None : string option) (* -init *) and use_prims = ref "" (* -use-prims ... *) and use_runtime = ref "" (* -use-runtime ... *) and principal = ref false (* -principal *) |