[Haskell-cafe] System.Process

Donn Cave donn at avvanta.com
Tue Sep 30 18:37:01 EDT 2008


Quoth David Roundy <droundy at darcs.net>:
...
| My point was that which of these is correct entirely depends on what
| your input is.  It's often a huge (and security-bug-prone) chore to
| escape all those shell characters, and so in many cases it's much
| nicer to execute an external program direcly without invoking a
| shell.

That's true, and in the other cases - when you want the shell to
process the command line - you should be able to invoke it.

I'm not looking at the source code (nor even running my example, since
I don't have ghc handy), but the basic difference is not "runCommand
parses the arguments", but "runCommand [only] invokes the shell".
If you want runProcess to invoke the shell:

   runProcess "/bin/sh" ["-c", commandLine] ...

(... ought to be ["sh", "-c" commandLine], but the way I remember it
ghc gratuitously prevents you from specifying argv 0.)

	Donn Cave, donn at avvanta.com

[I just sifted this thread out of ca. 300 spams and stuff, so please
pardon me if this has already been mentioned in another followup.]


More information about the Haskell-Cafe mailing list