Only initialise readline if we are connected to a terminal
authorIan Lynagh <igloo@earth.li>
Sun, 13 Jan 2008 12:41:07 +0000 (12:41 +0000)
committerIan Lynagh <igloo@earth.li>
Sun, 13 Jan 2008 12:41:07 +0000 (12:41 +0000)
Patch from Bertram Felgenhauer <int-e@gmx.de>

compiler/ghci/InteractiveUI.hs

index e4439d6..e712e9d 100644 (file)
@@ -299,13 +299,15 @@ interactiveUI session srcs maybe_expr = do
         hSetBuffering stdin NoBuffering
 
 #ifdef USE_READLINE
-        Readline.initialize
-        Readline.setAttemptedCompletionFunction (Just completeWord)
-        --Readline.parseAndBind "set show-all-if-ambiguous 1"
-
-        Readline.setBasicWordBreakCharacters word_break_chars
-        Readline.setCompleterWordBreakCharacters word_break_chars
-        Readline.setCompletionAppendCharacter Nothing
+        is_tty <- hIsTerminalDevice stdin
+        when is_tty $ do
+            Readline.initialize
+            Readline.setAttemptedCompletionFunction (Just completeWord)
+            --Readline.parseAndBind "set show-all-if-ambiguous 1"
+
+            Readline.setBasicWordBreakCharacters word_break_chars
+            Readline.setCompleterWordBreakCharacters word_break_chars
+            Readline.setCompletionAppendCharacter Nothing
 #endif
 
    -- initial context is just the Prelude