Skip to content

Commit ea6355b

Browse files
committed
Format ExitCodeException stdout and stderr with UTF-8
Closes #86 Thanks to @9999years for the legwork on this change
1 parent b99e450 commit ea6355b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ChangeLog for typed-process
22

3+
* Format stdout and stderr in `ExitCodeException` assuming they are in
4+
UTF-8. See [#87](https://github.com/fpco/typed-process/pull/87).
5+
Thanks to @9999years for the legwork on this change.
6+
37
## 0.2.12.0
48

59
* Add `getPid`, `exitCodeExceptionWithOutput`,

package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- bytestring
2020
- process >=1.2
2121
- stm
22+
- text
2223
- transformers
2324
- unliftio-core
2425

src/System/Process/Typed/Internal.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ import Control.Concurrent.Async (async)
2323
import Control.Concurrent.STM (newEmptyTMVarIO, atomically, putTMVar, readTMVar, STM, tryPutTMVar, throwSTM)
2424
import System.Exit (ExitCode)
2525
import qualified Data.ByteString.Lazy as L
26-
import qualified Data.ByteString.Lazy.Char8 as L8
2726
import Data.String (IsString (fromString))
2827
import Control.Monad.IO.Unlift
28+
import qualified Data.Text.Encoding.Error as TEE
29+
import qualified Data.Text.Lazy as TL
30+
import qualified Data.Text.Lazy.Encoding as TLE
2931

3032
#if MIN_VERSION_process(1, 4, 0) && !WINDOWS
3133
import System.Posix.Types (GroupID, UserID)
@@ -626,7 +628,7 @@ instance Show ExitCodeException where
626628
else "Standard error:\n\n" ++ unpack (eceStderr ece)
627629
]
628630
where
629-
unpack = L8.unpack
631+
unpack = TL.unpack . TLE.decodeUtf8With TEE.lenientDecode
630632

631633
-- | Wrapper for when an exception is thrown when reading from a child
632634
-- process, used by 'byteStringOutput'.

0 commit comments

Comments
 (0)