Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Scripting in ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Scripting in ocaml
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 `

Actually, even Perl isn't a very usable alternative for shell
scripting because of the amount of code you have to write just to fork
off a command and capture the output.


Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology -
Internet Marketing and AdWords courses - - NEW!
Merjis blog - - NEW!