From: Oleg Broytman Date: Thu, 30 Jan 2014 19:07:40 +0000 (+0400) Subject: Forbid filtering from console to console - show usage instead X-Git-Tag: v2.3.2~22 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=038d41eaa2ab37dba4988904463aac7bda5151e6;p=mimedecode.git Forbid filtering from console to console - show usage instead --- 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)