From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 7942FBC63 for ; Fri, 22 Dec 2006 00:36:24 +0100 (CET) Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBLNaN5Z021585 for ; Fri, 22 Dec 2006 00:36:24 +0100 Received: from out1.internal (unknown [10.202.2.149]) by out1.messagingengine.com (Postfix) with ESMTP id C970A59B5C; Thu, 21 Dec 2006 18:36:14 -0500 (EST) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by out1.internal (MEProxy); Thu, 21 Dec 2006 18:36:14 -0500 X-Sasl-enc: 5aVfYtxjbrGtabqiJVQv2NW1Vw05aCVjGooh4Y4p/NmK 1166744174 Received: from [172.16.112.115] (burnham.ljcrf.edu [192.231.106.2]) by mail.messagingengine.com (Postfix) with ESMTP id F0885AEEF; Thu, 21 Dec 2006 18:36:13 -0500 (EST) Date: Thu, 21 Dec 2006 15:35:31 -0800 (PST) From: Martin Jambon X-X-Sender: martin@localhost To: Richard Jones Cc: Denis Bueno , OCaml Mailing List Subject: Re: [Caml-list] Scripting in ocaml In-Reply-To: <20061221145953.GA24045@furbychan.cocan.org> Message-ID: References: <6dbd4d000612201941wcd4b09anc503a13889576512@mail.gmail.com> <20061221145953.GA24045@furbychan.cocan.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-j-chkmail-Score: MSGID : 458B1A77.004 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 458B1A77.004 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 camlp:01 syntax:01 foo:01 foo:01 camlp:01 syntax:01 pipelines:01 subset:01 1977:98 20,:98 wrote:01 wrote:01 preprocessor:01 On Thu, 21 Dec 2006, Richard Jones wrote: > On Wed, Dec 20, 2006 at 10:41:20PM -0500, Denis Bueno wrote: > > I've been writing bash scripts to perform various build- and > > development-related tasks, and I don't enjoy it. I won't bore you with > > detailed reasons why. The upshot is that I'd like to script in OCaml. > > > > I have considered writing a few camlp4 extensions to make it easier to > > write scripts: > > > > 1) create a syntax which grabs environment variables: > > > > e.g. $FOO would grab the value of the environment variable FOO > > > > 2) some sort of more convenient process interaction, e.g., for piping. > > I think it's a great idea - I'd love to push OCaml for scripting. > However I hope your camlp4-fu is up to snuff. You'd want, as you say, > a syntax for pipelines and file redirection, but more importantly > you'd want a very simple syntax for running commands. So you can > write some unholy OCaml/sh combination like: > > let nr_files = int_of_string ` ls | wc -l ` It's something that I'd love to have too. An implementation of a simple subset of sh would be nice. The programming features would be handled by ocaml, so we need a way to use ocaml variables as shell variables (of type string, string list or command) in addition to environment variables. Should camlp4's quotations be used for this, or should the special syntax be handled by another preprocessor? I don't know. A quotation looks like << ls | wc -l >> or <:cmd< ls | wc -l >>. If something like this already exists, please let us know. If not, I'd be glad to help design the thing. Martin -- Martin Jambon, PhD http://martin.jambon.free.fr