From b13ae91698316ba1e3646b85ebe13cb8004b2df9 Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Sun, 14 Oct 2012 07:33:33 -0400 Subject: [PATCH] It's ok to decompress a text file to a TTY --- pixz.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pixz.c b/pixz.c index 22bf3ff..7b318dc 100644 --- a/pixz.c +++ b/pixz.c @@ -110,11 +110,13 @@ int main(int argc, char **argv) { die("Can't open input file"); if (opath && !(gOutFile = fopen(opath, "w"))) die("Can't open output file"); - if (op != OP_LIST && isatty(fileno(gOutFile)) == 1) - usage("Refusing to output to a TTY"); switch (op) { - case OP_WRITE: pixz_write(tar, level); break; + case OP_WRITE: + if (isatty(fileno(gOutFile)) == -1) + usage("Refusing to output to a TTY"); + pixz_write(tar, level); + break; case OP_READ: pixz_read(tar, 0, NULL); break; case OP_EXTRACT: pixz_read(tar, argc, argv); break; case OP_LIST: pixz_list(tar);