From 36fc23d692a6dc5a220265d6a4b8faf1a9fe019e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 20 Sep 2018 11:05:00 -0400 Subject: [PATCH] Avoid VT control codes on exit through pipe Piped commands were subjected to terminal control sequences that could interfere with desired operation. --- confluent_client/bin/confetty | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index 86ef1aea..6ad1896c 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -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: