diff options
author | Joey Hess <joey@kitenet.net> | 2012-02-03 01:38:23 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-02-03 01:41:14 -0400 |
commit | fb78107f85ffbd83c7c8dad6bfcaa8374387cccc (patch) | |
tree | 666b6bbf8dc065203022f666aa742a3d8bb615c1 /Messages.hs | |
parent | 3d49258e5bed4d9a6ec9e24ddb776f277542664b (diff) |
add a check for not utf-8 console
Diffstat (limited to 'Messages.hs')
-rw-r--r-- | Messages.hs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Messages.hs b/Messages.hs index 844c6bfc5..ff5287d80 100644 --- a/Messages.hs +++ b/Messages.hs @@ -119,18 +119,16 @@ showHeader h = handle q $ showRaw :: String -> Annex () showRaw s = handle q $ putStrLn s -{- By default, haskell honors the user's locale in its output to stdout - - and stderr. While that's great for proper unicode support, for git-annex - - all that's really needed is the ability to display simple messages - - (currently untranslated), and importantly, to display filenames exactly - - as they are written on disk, no matter what their encoding. So, force - - raw mode. - - - - NB: Once git-annex gets localized, this will need a rethink. -} +{- This check is done because the code assumes filenames are utf8 encoded, + - using decodeUtf8 and Codec.Binary.UTF8.String.encodeString. So if + - run in a non unicode locale, it will crash or worse, possibly operate + - on the wrong file. + -} setupConsole :: IO () -setupConsole = return () - --hSetBinaryMode stdout True - --hSetBinaryMode stderr True +setupConsole + | show localeEncoding == show utf8 = return () + | otherwise = error $ + "Sorry, only UTF-8 locales are currently supported." handle :: IO () -> IO () -> Annex () handle json normal = Annex.getState Annex.output >>= go |