diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2010-01-13 19:10:25 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2010-01-13 19:10:25 +0200 |
commit | 3ffd5d81a43210c8da56da5c5b3637d3f8bc63c7 (patch) | |
tree | b6322fb646dab29760b5631df6d8ff10ca829f46 /src/xz/main.c | |
parent | Don't compress or decompress special files unless writing (diff) | |
download | xz-3ffd5d81a43210c8da56da5c5b3637d3f8bc63c7.tar.xz |
Don't read compressed data from a terminal or write it
to a terminal even if --force is specified.
It just seems more reasonable this way.
The new behavior matches bzip2. The old one matched gzip.
Diffstat (limited to 'src/xz/main.c')
-rw-r--r-- | src/xz/main.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/xz/main.c b/src/xz/main.c index b197ca43..7445e98a 100644 --- a/src/xz/main.c +++ b/src/xz/main.c @@ -168,8 +168,8 @@ main(int argc, char **argv) message_set_files(args.arg_count); // Refuse to write compressed data to standard output if it is - // a terminal and --force wasn't used. - if (opt_mode == MODE_COMPRESS && !opt_force) { + // a terminal. + if (opt_mode == MODE_COMPRESS) { if (opt_stdout || (args.arg_count == 1 && strcmp(args.arg_names[0], "-") == 0)) { if (is_tty_stdout()) { @@ -188,16 +188,14 @@ main(int argc, char **argv) // were given, parse_args() gave us a fake "-" filename. for (size_t i = 0; i < args.arg_count && !user_abort; ++i) { if (strcmp("-", args.arg_names[i]) == 0) { - // Processing from stdin to stdout. Unless --force - // was used, check that we aren't writing compressed - // data to a terminal or reading it from terminal. - if (!opt_force) { - if (opt_mode == MODE_COMPRESS) { - if (is_tty_stdout()) - continue; - } else if (is_tty_stdin()) { + // Processing from stdin to stdout. Check that we + // aren't writing compressed data to a terminal or + // reading it from a terminal. + if (opt_mode == MODE_COMPRESS) { + if (is_tty_stdout()) continue; - } + } else if (is_tty_stdin()) { + continue; } // It doesn't make sense to compress data from stdin |