Merge pull request #53 from icychkn/master

Added check to avoid stty error when stdin is redirected
This commit is contained in:
Karl Voit 2023-06-19 15:03:57 +02:00 committed by GitHub
commit ca87aaf067
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,10 +81,14 @@ if platform.system() == 'Windows':
TTY_HEIGHT, TTY_WIDTH = 80, 80 # fall-back values
IS_WINDOWS = True
else:
try:
TTY_HEIGHT, TTY_WIDTH = [int(x) for x in os.popen('stty size', 'r').read().split()]
except ValueError:
TTY_HEIGHT, TTY_WIDTH = 80, 80 # fall-back values
# check to avoid stty error when stdin is not a terminal.
if sys.stdin.isatty():
try:
TTY_HEIGHT, TTY_WIDTH = [int(x) for x in os.popen('stty size', 'r').read().split()]
except ValueError:
TTY_HEIGHT, TTY_WIDTH = 80, 80 # fall-back values
else:
TTY_HEIGHT, TTY_WIDTH = 80, 80
max_file_length = 0 # will be set after iterating over source files182