Re: Sys.argv with interpreter and compiler

From: Xavier Leroy (
Date: Thu Jul 01 1999 - 19:32:22 MET DST

Date: Thu, 1 Jul 1999 19:32:22 +0200
From: Xavier Leroy <>
To: Markus Mottl <>, OCAML <>
Subject: Re: Sys.argv with interpreter and compiler
In-Reply-To: <>; from Markus Mottl on Sun, Jun 27, 1999 at 01:02:45PM +0100

> E.g. I want to emit an error message that includes the name of the
> executable or, if the interpreter is used, the name of the script.
> Wouldn't it be logically more consistent to pass the truncated array
> of arguments to the script under the interpreter so that the program
> always gets its name on index 0 - no matter whether it is compiled
> or interpreted?

Yes, it would be more consistent, but that's exactly what it does
currently. At least, that's what a quick test under Linux shows.

> - With the current version it gets the name of the
> interpreter on this position.

That's surprising. On which operating system do you see this
behavior? The treatment of argv[0] in C w.r.t. #! scripts differs
between various versions of Unix, but we tried to compensate for this
in the OCaml bytecode interpreter.

- Xavier Leroy

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:23 MET