@@ -16,6 +16,7 @@ module Util.System( tempfile
16 , readSource
16 , readSource
17 , setupBundledCC
17 , setupBundledCC
21import Control.Exception as CE
22import Control.Exception as CE
@@ -38,6 +39,11 @@ import System.FilePath (dropFileName, isAbsolute, searchPathSeparator)
38import Tools_idris
39import Tools_idris
42+#ifdef mingw32_HOST_OS
43+import Graphics.Win32.Misc (getStdHandle, sTD_OUTPUT_HANDLE)
44+import System.Console.MinTTY (isMinTTYHandle)
41catchIO :: IO a -> (IOError -> IO a) -> IO a
47catchIO :: IO a -> (IOError -> IO a) -> IO a
42catchIO = CE.catch
48catchIO = CE.catch
@@ -70,6 +76,20 @@ isATTY = do
70 tty <- isATTYRaw 1 -- fd stdout
76 tty <- isATTYRaw 1 -- fd stdout
71 return $ tty /= 0
77 return $ tty /= 0
79+-- | Return 'True' if the process's standard output is attached to a MinTTY
80+-- console (e.g., Cygwin or MSYS) on Windows. Return 'False' otherwise.
82+-- Unfortunately, we must check this separately since 'isATTY' always returns
83+-- 'False' on MinTTY consoles.
85+#ifdef mingw32_HOST_OS
87+ h <- getStdHandle sTD_OUTPUT_HANDLE
90+isMinTTY = return False
73withTempdir :: String -> (FilePath -> IO a) -> IO a
93withTempdir :: String -> (FilePath -> IO a) -> IO a
74withTempdir subdir callback
94withTempdir subdir callback
75 = do dir <- getTemporaryDirectory
95 = do dir <- getTemporaryDirectory