-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBit.hs
More file actions
24 lines (21 loc) · 886 Bytes
/
Bit.hs
File metadata and controls
24 lines (21 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE ScopedTypeVariables #-}
import Bit.Commands
import GHC.IO.Encoding (setLocaleEncoding, utf8)
import System.IO (hSetEncoding, stdout, stderr, hIsTerminalDevice)
import System.Info (os)
import System.Process (callCommand)
import Control.Exception (catch, SomeException)
import Control.Monad (when)
main :: IO ()
main = do
-- Set console to UTF-8 on Windows (only when interactive)
-- Skip during automated tests to avoid git binary file issues
isTerminal <- hIsTerminalDevice stdout
when (os == "mingw32" && isTerminal) $
callCommand "chcp 65001 > nul 2>&1" `catch` \(_ :: SomeException) -> pure ()
-- Set UTF-8 for all IO (stdout, stderr, and subprocess pipes)
-- This ensures readProcessWithExitCode decodes git output as UTF-8
setLocaleEncoding utf8
hSetEncoding stdout utf8
hSetEncoding stderr utf8
Bit.Commands.run