andrewcoppin at btinternet.com
Mon Sep 29 15:49:44 EDT 2008
Much hair-pulling resulted today when I attempted to perform a small task.
The System.Process module provides the runCommand function. This takes a
complete command line and returns a ProcessHandle. No problem there.
The module also provides the runProcess function, which enables you to
set environment variables and so forth. However... this doesn't take a
complete command line. It takes a path to an executable and a list of
Herein lies the problem: I have a program that accepts complete commands
from a file and executes them. It works perfectly. And now I'd just like
to set an environment variable while each command runs... But alas no,
the only way to do that is with runProcess, which expects me to parse
the command line first. (Before anybody remarks that "words" will do
this, consider the "echo" command, which treats whitespace meaningfully.)
In the end I resorted to reading the source code for the module. After
about 30 minutes of hacking, I got something which typechecks but throws
a runtime exception. It appears that runCommand looks for binaries in
the system search path, but the code I've concocted doesn't. (Despite
being cut and pasted from the definition of runCommand.) The only thing
I can think of is that the source code I'm looking at (GHC 6.8.3) is
different from the version of the library I have (GHC 6.8.1).
Anyway, the point I'm trying to get to is... would it be hard for
however maintains this library to add a little more flexibility in what
it can do please?
More information about the Haskell-Cafe