[Haskell-cafe] How to add ENV variable in runhaskell shell script

Liyang HU haskell.org at liyang.hu
Sun Jan 13 23:16:41 EST 2008


Hi,

On 1/14/08, Steve Lihn <stevelihn at gmail.com> wrote:
> In perl scripts (unix), one can do
> #!/usr/local/bin/perl
> BEGIN { $ENV{LD_LIBRARY_PATH} = ...; }

I've not tested this (what a great line to start a post...), but see
if this works for you:

     #! /usr/bin/env LD_LIBRARY_PATH=/path/to/libs runhaskell

which also has the (desirable? Hmm...) side effect of letting env
figure out (using PATH) where to find runhaskell.

This doesn't work for compiled binaries, sadly.

Modifying LD_LIBRARY_PATH at runtime works for Perl because libraries
are loaded at runtime, and the language allows you to sneak in some
code before that happens. Even if Haskell had a
System.Environment.withEnv (it already has a withArgs), it's probably
too late to patch the environment -- you can't get in before the
linker. (Unless you're using some sort of funky dynamic plugin thing.)

Cheers,
/Liyang



More information about the Haskell-Cafe mailing list