From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA25625 for caml-redistribution; Tue, 6 Apr 1999 18:35:02 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA18226 for ; Tue, 6 Apr 1999 11:31:36 +0200 (MET DST) Received: from transbay.net (dns1.transbay.net [209.133.53.2]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id LAA17345 for ; Tue, 6 Apr 1999 11:31:34 +0200 (MET DST) Received: from kronstadt.transbay.net (ip55243.transbay.net [209.133.55.243]) by transbay.net (8.9.1/8.8.8) with ESMTP id CAA18519 for ; Tue, 6 Apr 1999 02:32:53 -0700 (PDT) (envelope-from itz@transbay.net) Received: (from itz@localhost) by kronstadt.transbay.net (8.8.6/8.8.6) id BAA01366; Tue, 6 Apr 1999 01:07:42 -0700 Sender: weis To: caml-list@inria.fr Subject: Toplevel script mode From: Ian T Zimmerman Date: 06 Apr 1999 01:07:27 -0700 Message-ID: X-Mailer: Gnus v5.3/Emacs 19.34 Here's some code from ocaml-2.02/toplevel/toploop.ml: [...] (* Toplevel initialization. Performed here instead of at the beginning of loop() so that user code linked in with ocamlmktop can call directives from Topdirs. *) let _ = Sys.interactive := true; Symtable.init_toplevel(); Clflags.thread_safe := true; Compile.init_path() let load_ocamlinit () = if Sys.file_exists ".ocamlinit" then ignore(use_silently ".ocamlinit") (* The interactive loop *) [...] (* Execute a script *) let run_script name = Compile.init_path(); toplevel_env := Compile.initial_env(); Format.set_formatter_out_channel stderr; use_silently name So, in script mode, Compile.init_path() is called twice, defeating the purpose of hoisting it into pre-main code in the first place, as the first comment explains it. I think this is a bug. Also, I don't see any reason why script mode should omit calling .ocamlinit. It does present a security risk, I think, but that applies to the interactive case as well, and should be best handled by adding a command line option to the toplevel to disable it. Here's a patch (without the new option :-) --- /home/itz/toploop.ml Tue Apr 6 00:57:59 1999 +++ /usr/src/ocaml-2.02/toplevel/toploop.ml Sat Apr 3 23:33:31 1999 @@ -311,7 +311,7 @@ (* Execute a script *) let run_script name = - Compile.init_path(); toplevel_env := Compile.initial_env(); Format.set_formatter_out_channel stderr; + load_ocamlinit (); use_silently name -- Ian T Zimmerman I came to the conclusion that what was wrong about the guillotine was that the condemned man had no chance at all, absolutely none. Albert Camus, _The Outsider_