From: Ian T Zimmerman <itz@transbay.net>
To: caml-list@inria.fr
Subject: Toplevel script mode
Date: 06 Apr 1999 01:07:27 -0700 [thread overview]
Message-ID: <m2zp4m2mv4.fsf@kronstadt.transbay.net> (raw)
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 <itz@transbay.net>
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_
next reply other threads:[~1999-04-06 16:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-04-06 8:07 Ian T Zimmerman [this message]
1999-04-06 8:43 Ian T Zimmerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2zp4m2mv4.fsf@kronstadt.transbay.net \
--to=itz@transbay.net \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox