Skip to content

Commit e2cef83

Browse files
committed
Make sure stdout is a terminal before running 'stty sane'
1 parent ea39489 commit e2cef83

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cmd2/cmd2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,8 +1787,9 @@ def _run_cmdfinalization_hooks(self, stop: bool, statement: Optional[Statement])
17871787
"""Run the command finalization hooks"""
17881788

17891789
with self.sigint_protection:
1790-
if not sys.platform.startswith('win') and self.stdin.isatty():
1791-
# Fix those annoying problems that occur with terminal programs like "less" when you pipe to them
1790+
if not sys.platform.startswith('win') and self.stdout.isatty():
1791+
# Before the next command runs, fix any terminal problems like those
1792+
# caused by certain binary characters having been printed to it.
17921793
import subprocess
17931794
proc = subprocess.Popen(['stty', 'sane'])
17941795
proc.communicate()

0 commit comments

Comments
 (0)