From 2a8295d71ce8eecd55f7818cc48cc496c3202ad4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 14 Jun 2018 21:53:13 +0530 Subject: [PATCH] diff kitten: Better error message when one of the arguments does not exist --- kittens/diff/main.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kittens/diff/main.py b/kittens/diff/main.py index 573c6c3e0..6741b2e50 100644 --- a/kittens/diff/main.py +++ b/kittens/diff/main.py @@ -399,11 +399,9 @@ 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') + for f in left, right: + if not os.path.exists(f): + raise SystemExit('{} does not exist'.format(f)) loop = Loop() handler = DiffHandler(args, opts, left, right)