2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-26 03:19:48 +00:00

Only conditionally import readline

If stdout is not a tty, do not import readline.  import
readline by itself can cause terminal control characters
to appear in the stdout.  Avoid this by only importing if
there seems to be a sign it is connected to a terminal.
This commit is contained in:
Jarrod Johnson 2015-06-26 15:26:44 -04:00
parent 86f66e9795
commit 186929d217

View File

@ -46,7 +46,6 @@ import math
import getpass
import optparse
import os
import readline
import select
import shlex
import socket
@ -601,9 +600,11 @@ except socket.gaierror:
# sys.stdout.write('\x1b[H\x1b[J')
# sys.stdout.flush()
readline.parse_and_bind("tab: complete")
readline.parse_and_bind("set bell-style none")
readline.set_completer(completer)
if sys.stdout.isatty():
import readline
readline.parse_and_bind("tab: complete")
readline.parse_and_bind("set bell-style none")
readline.set_completer(completer)
doexit = False
inconsole = False
pendingcommand = ""