Make the icat kitten work even if stdout/stdin are redirected

This commit is contained in:
Kovid Goyal 2018-06-06 12:04:10 +05:30
parent 8a1a45b067
commit c76a8242e2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -264,10 +264,8 @@ def main(args=sys.argv):
print('{}x{}'.format(ss.width, ss.height), end='') print('{}x{}'.format(ss.width, ss.height), end='')
raise SystemExit(0) raise SystemExit(0)
if not sys.stdout.isatty() or not sys.stdin.isatty(): if not sys.stdout.isatty():
raise SystemExit( sys.stdout = open('/dev/tty', 'w')
'Must be run in a terminal, stdout and/or stdin is currently not a terminal'
)
screen_size = screen_size_function() screen_size = screen_size_function()
signal.signal(signal.SIGWINCH, lambda signum, frame: setattr(screen_size, 'changed', True)) signal.signal(signal.SIGWINCH, lambda signum, frame: setattr(screen_size, 'changed', True))
if screen_size().width == 0: if screen_size().width == 0: