From 038d41eaa2ab37dba4988904463aac7bda5151e6 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 30 Jan 2014 23:07:40 +0400 Subject: [PATCH] Forbid filtering from console to console - show usage instead --- TODO | 1 - mimedecode.py | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index bd35fb7..e69de29 100644 --- a/TODO +++ b/TODO @@ -1 +0,0 @@ -Forbid filtering stdin to stdout - require one of them to be a file. diff --git a/mimedecode.py b/mimedecode.py index f46165b..34c495f 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -389,6 +389,10 @@ if __name__ == "__main__": else: usage(1, 'Too many arguments') + if (infile is sys.stdin) and (outfile is sys.stdout) and \ + sys.stdin.isatty() and sys.stdout.isatty(): + usage(1, 'Filtering from console to console is forbidden') + gopts.outfile = outfile decode_file(infile) -- 2.39.5