@@ -33,6 +33,7 @@ import Data.Monoid ((<>))
3333import Data.Text (Text)
3434import qualified Data.Text as T
3535import qualified Data.Text.Encoding as T
36+import Data.Text.Encoding.Error (lenientDecode)
3637import System.Exit (ExitCode (..))
3738import System.IO (Handle)
3839import System.IO.Streams (InputStream, handleToInputStream)
@@ -64,7 +65,7 @@ readProcessAndLogStderr
6465readProcessAndLogStderr sev process = do
6566 (out, _err) <- withProcess process $ \_out err -> do
6667 streamToLog =<< liftIO (streamHandle sev err)
67− liftIO $ T.decodeUtf8 <$> BS.hGetContents out
68+ liftIO $ T.decodeUtf8With lenientDecode <$> BS.hGetContents out
6869
6970readCreateProcessWithExitCode
7071 :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e)
@@ -89,7 +90,7 @@ readProcessAndLogOutput (sev_out, sev_err) process = do
8990
9091 -- TODO interleave stdout and stderr in log correctly
9192 streamToLog =<< liftIO (streamHandle sev_err err)
92− outText <- liftIO $ T.decodeUtf8 <$> BS.hGetContents out
93+ outText <- liftIO $ T.decodeUtf8With lenientDecode <$> BS.hGetContents out
9394 putLogRaw sev_out outText
9495
9596 liftIO (waitForProcess p) >>= \case
@@ -173,7 +174,7 @@ streamToLog
173174streamToLog stream = fix $ \loop -> do
174175 liftIO (Streams.read stream) >>= \case
175176 Nothing -> return ()
176− Just (sev, line) -> putLogRaw sev (T.decodeUtf8 line) >> loop
177+ Just (sev, line) -> putLogRaw sev (T.decodeUtf8With lenientDecode line) >> loop
177178
178179-- | Pretty print a 'CmdSpec'
179180reconstructCommand :: Process.CmdSpec -> Text