From d8021ef754c9572b3909a7f8e4578e7deaf8848a Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 23 Oct 2023 13:59:25 +0100 Subject: [PATCH] fix:demo: avoid breaking asciinema 2.3.0 (fix #2094) We were adding a trailing newline, which causes asciinema 2.3.0 to show a JSON decode error. --- hledger/Hledger/Cli/Commands/Demo.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hledger/Hledger/Cli/Commands/Demo.hs b/hledger/Hledger/Cli/Commands/Demo.hs index 772ad159b..83cda62a1 100644 --- a/hledger/Hledger/Cli/Commands/Demo.hs +++ b/hledger/Hledger/Cli/Commands/Demo.hs @@ -148,8 +148,11 @@ printDemos = putStrLn $ unlines $ -- | Run asciinema play with the given speed and idle limit, passing the given content to its stdin. runAsciinemaPlay :: Float -> Float -> ByteString -> [String] -> IO () runAsciinemaPlay speed idlelimit content args = - withSystemTempFile "hledger-cast" $ \f h -> do -- try piping to stdin also - B.hPutStrLn h content >> hClose h + -- XXX try piping to stdin also + withSystemTempFile "hledger-cast" $ \f h -> do + -- don't add an extra newline here, it breaks asciinema 2.3.0 (#2094). + -- XXX we could try harder and strip excess newlines/carriage returns+linefeeds here + B.hPutStr h content >> hClose h callProcess "asciinema" (dbg8With (("asciinema: "++).unwords) $ concat [ ["play"] ,["-s"<> showwithouttrailingzero speed]