2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Avoid VT control codes on exit through pipe

Piped commands were subjected to terminal control sequences that
could interfere with desired operation.
This commit is contained in:
Jarrod Johnson 2018-09-20 11:05:00 -04:00
parent cf3e9037ab
commit 36fc23d692

View File

@ -598,9 +598,10 @@ def quitconfetty(code=0, fullexit=False, fixterm=True):
if oldtcattr is not None:
termios.tcsetattr(sys.stdin.fileno(), termios.TCSANOW, oldtcattr)
# Request default color scheme, to undo potential weirdness of terminal
sys.stdout.write('\x1b[m')
if sys.stdout.isatty():
sys.stdout.write('\x1b[m')
if fullexit:
if os.environ.get('TERM', '') not in ('linux'):
if sys.stdout.isatty() and os.environ.get('TERM', '') not in ('linux'):
sys.stdout.write('\x1b]0;\x07')
sys.exit(code)
else: