Problem with ghc on Windows ME

Glynn Clements glynn.clements at virgin.net
Thu Jan 29 17:04:43 EST 2004


C.Reinke wrote:

> Therefore, my suggestion would be to keep the rawSystem from
> ghc-6.0.1 (which doesn't seem to do any interpretation?), and
> to provide a system-specific escape function
> 
>   System.Cmd.escape :: String -> String -> String
>   -- (System.Cmd.escape chars string) escapes occurrences of 
>   -- chars in string, according to convention on the current
>   -- system
> 
> If really necessary, there could be a convenience function
> somewhat like:
> 
>   -- try to do "the right thing"
>   System.Cmd.rawSystem' :: String -> [String] -> IO ExitCode
>   System.Cmd.rawSystem' path args =
>     rawSystem $ concat (path:[' ':(escape "\\\"" a) | a <- args])

That sounds is if it makes sense, but it doesn't. At least, not on
Unix. On Unix, there are two basic options for invoking another
program:

1. Use the shell, i.e. system(). Pass a single string which will
undergo all of the various forms of processing which the shell
performs.

2. Don't use the shell. Pass a list of strings which become the
argv[i] of the called program.

If you don't want any processing, the correct solution is to bypass
the shell altogether, *not* to attempt to subject the string to an
inverse transformation in the hope that the shell will eventually end
up passing the desired argv[i] to the called program.

-- 
Glynn Clements <glynn.clements at virgin.net>


More information about the Glasgow-haskell-users mailing list