Allow the diff kitten to work even if stdout/stdin are redirected

Now directly opens /dev/tty
This commit is contained in:
Kovid Goyal 2018-06-06 12:01:47 +05:30
parent 8f433f5ff6
commit 8a1a45b067
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -399,6 +399,11 @@ def main(args):
opts = init_config(args)
set_diff_command(opts.diff_cmd)
lines_for_path.replace_tab_by = opts.replace_tab_by
# Ensure the kitten works even when stdin/stdout are redirected
if not sys.stdin.isatty():
sys.stdin = open('/dev/tty')
if not sys.stdout.isatty():
sys.stdout = open('/dev/tty', 'w')
loop = Loop()
handler = DiffHandler(args, opts, left, right)