[Haskell-cafe] runInteractiveProcess and hGetLine on Windows

David Roundy droundy at darcs.net
Wed May 7 11:21:03 EDT 2008


On Wed, May 07, 2008 at 04:42:45PM +0200, Harri Kiiskinen wrote:
> Prelude System.Process System.IO> (inp,outp,err,ph) <-
> 	runInteractiveProcess "kpsewhich" ["testfile.txt"] Nothing
> 		Nothing
...
> Prelude System.Process System.IO> hGetLine outp
> 
> which gives me:
> 
> "./testfile.txt\r"
> 
> as opposed to "./testfile.txt" which I get on my Linux box.
> 
> Is the "\r" supposed to be at the end? I thought it is part of the line
> separator in Windows, and as such, should not be part of the line
> retrieved? Same thing happens when compiled with ghc.

This is the correct behavior (although it's debatable whether kpsewhich
should be outputting in text mode).  In order to get windows-style line
handling, a file handle needs to be opened in text mode, which is certainly
not the correct behavior for runInteractiveProcess, which has no knowledge
about the particular behavior of the program it's running.

"\r\n" as newline should die a rapid death... windows is hard enough
without maintaining this sort of stupidity.
-- 
David Roundy
Department of Physics
Oregon State University


More information about the Haskell-Cafe mailing list