Reading a strict text from a process that produces raw bytes fails due to an encoding error and we get a reasonable exception:
> :m System.Exit System.Process.ListLike Data.Text
> readCreateProcessWithExitCode (shell "gzip -v < /proc/uptime") mempty :: IO (ExitCode,Text,Text)
*** Exception: fd:14: hGetContents: invalid argument (invalid byte sequence)
However, if we do the same thing with a lazy text, we get an exception relating to hClose rather than the encoding:
> :m System.Exit System.Process.ListLike Data.Text.Lazy
> readCreateProcessWithExitCode (shell "gzip -v < /proc/uptime") mempty :: IO (ExitCode,Text,Text)
*** Exception: fd:14: hClose: invalid argument (Bad file descriptor)
In any case the reading succeeds with either strict or lazy bytestrings (because no text encoding is required):
> :m System.Exit System.Process.ListLike Data.ByteString
> readCreateProcessWithExitCode (shell "gzip -v < /proc/uptime") mempty :: IO (ExitCode,ByteString,ByteString)
(ExitSuccess,"\US\139\b\NUL\192\132\208[\NUL\ETX3\179\&4\180\212\&37R045\183\180\208\&34\227\STX\NUL\182\150\238:\DC1\NUL\NUL\NUL","gzip: stdin: file size changed while zipping\n-11.8%\n")
> :m System.Exit System.Process.ListLike Data.ByteString.Lazy
> readCreateProcessWithExitCode (shell "gzip -v < /proc/uptime") mempty :: IO (ExitCode,ByteString,ByteString)
(ExitSuccess,"\US\139\b\NUL\203\132\208[\NUL\ETX3\179\&46\212\&36V04\181\&01\214\179\&4\228\STX\NUL\247H\237\US\DC1\NUL\NUL\NUL","gzip: stdin: file size changed while zipping\n-11.8%\n")
Reading a strict text from a process that produces raw bytes fails due to an encoding error and we get a reasonable exception:
However, if we do the same thing with a lazy text, we get an exception relating to hClose rather than the encoding:
In any case the reading succeeds with either strict or lazy bytestrings (because no text encoding is required):