Skip to content
  • Duncan Coutts's avatar
    Use rawSystem not system for capturing output of commands · 1cbfb5e0
    Duncan Coutts authored
    For example we were using a wrapper around 'system' to find the haddock
    version. This invokes the system command interpreter and passes the
    command to run as an argument. If the command has spaces in it and is not
    properly escaped then everything goes wrong. This happens for example
    on windows when haddock and other programs are kept under "Program Files".
    So the right thing to do is never to use system, but always rawSystem since
    then there are no escaping issues.
    
    This patch replaces a couple function systemCaptureStdout and systemGetStdout
    with rawSystemStdout which now lives in Distribution.Simple.Utils.
    
    This also uses some rather nasty code to get the output of a command.
    It really really should not be this hard to do portably. To work around
    the fact that we cannot use runInteractiveProcess we instead have to create
    a temporary file. This also turns out to be a hack because the 'standard'
    openTempFile is not implemented except by GHC, so we now have a hacky version
    living in Distribution.Compat.TempFile just waiting for the standard 
    openTempFile to be made properly portable, or for us to get some
    System.Process function that does what we want.
    1cbfb5e0