On Thu, Aug 11, 2011 at 11:29, Charles-Pierre Astolfi <cpa@crans.org> wrote:
I've found my mistake: I was calling readProcess cmd ["-p -t"] instead
of readProcess cmd ["-p","-t"]

Not sure what are the semantics of quotation in this case, though. And
I'm pretty sure my analysis is wrong because of that :)

It's quite simple:  readProcess uses the low level exec*() series of functions under the hood.  Quoting is assumed to have already been dealt with; every parameter is a separate String (or (char *) in the C API) and passed literally.

Quoting is used at the shell level (and shell-based APIs such as system()) to enable the shell to correctly generate a list of literal (char *) parameters.

In general, if an exec-style API takes a list of strings (e.g. C execve(), Haskell readProcess, Perl's multiple-parameter form of system), it's using the exec()-based API and you should pass argument strings exactly as you want the program to see them; if its a single string, it's using a system()-based API and you need to worry about quoting.  In this case, the tip-off is that the argument list is a [String] and not simply a String.

--
brandon s allbery                                      allbery.b@gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms