From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 7D465BB9C for ; Fri, 20 Jan 2006 03:24:31 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0K2OUJM024294 for ; Fri, 20 Jan 2006 03:24:31 +0100 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 DAA17893 for ; Fri, 20 Jan 2006 03:24:30 +0100 (MET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k0K2OSjq015153 for ; Fri, 20 Jan 2006 03:24:29 +0100 Received: from rosella (ppp21-250.lns2.syd7.internode.on.net [59.167.21.250]) by smtp1.adl2.internode.on.net (8.13.5/8.13.5) with ESMTP id k0K2O3O6043512; Fri, 20 Jan 2006 12:54:19 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] toplevel with pre-installed printers From: skaller To: Richard Jones Cc: caml-list@inria.fr In-Reply-To: <20060119201847.GA28585@furbychan.cocan.org> References: <43CFBE3E.1090808@andrej.com> <43CFC776.3060801@andrej.com> <20060119174907.GA309@furbychan.cocan.org> <20060119191259.GB12416@localhost> <20060119201847.GA28585@furbychan.cocan.org> Content-Type: text/plain Date: Fri, 20 Jan 2006 13:24:03 +1100 Message-Id: <1137723843.8822.139.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 43D049DF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43D049DC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 toplevel:01 getcwd:01 non-ocaml:01 gcc:01 argv:01 symlink:01 binary:01 symlink:01 argv:01 pathname:01 toplevel:01 unix:01 unix:01 wrote:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Thu, 2006-01-19 at 20:18 +0000, Richard Jones wrote: > On Thu, Jan 19, 2006 at 02:12:59PM -0500, Eric Cooper wrote: > > In a single "master" .ocamlinit, you could dispatch on > > Sys.executable_name, and perhaps Sys.getcwd. Still a hack, but it > > might avoid (non-OCaml) wrapper scripts. > > This is a clever idea. It's an old one too. gcc does it. The problem is portability. You simply look at argv[0] which on some Unix systems is the full path name of the invoked executable. In particular, its the path name of the symlink to the executable, not the binary. Thus, you can find the directory containing the symlink, and thus the resources associated with that particular symlink. All you need is a unique symlink for every context, and a fixed way of finding files relative to the location of the symlink. The problem is that there is no guarantee argv[0] is in fact the full pathname of the symlink on all Unix systems .. it works on Linux though. The two other techniques commonly used to solve this problem are (a) a wrapper script passing a command line argument (b) an environment variable ./ocamlinit script can certainly read an environment variable. It can also read the command line arguments .. so all you really need is to ask for a patch to the toplevel which allows you to pass it an argument it totally ignores! -- John Skaller Felix, successor to C++: http://felix.sf.net