* archival/bunzip2.c (bunzip2_main): Do not remove files if writing to standard
authorMatt Kraai <kraai@debian.org>
Mon, 15 Apr 2002 15:01:37 +0000 (15:01 -0000)
committerMatt Kraai <kraai@debian.org>
Mon, 15 Apr 2002 15:01:37 +0000 (15:01 -0000)
  output.
* testsuite/bunzip2/bzcat-does-not-remove-compressed-file: New.

archival/bunzip2.c
testsuite/bunzip2/bzcat-does-not-remove-compressed-file [new file with mode: 0644]

index a7b41b7d1fdc7e29380c900c559dd8dec05858d8..f2d514912bc941a53cc9aa8d6e4b079df68019eb 100644 (file)
@@ -2373,11 +2373,11 @@ int bunzip2_main(int argc, char **argv)
        }
 
        if (uncompressStream(src_stream, dst_stream)) {
-               if (save_name != NULL)
+               if (!(flags & bunzip_to_stdout))
                        delete_name = argv[optind];
                status = EXIT_SUCCESS;
        } else {
-               if (save_name != NULL)
+               if (!(flags & bunzip_to_stdout))
                        delete_name = save_name;
                status = EXIT_FAILURE;
        }
diff --git a/testsuite/bunzip2/bzcat-does-not-remove-compressed-file b/testsuite/bunzip2/bzcat-does-not-remove-compressed-file
new file mode 100644 (file)
index 0000000..7d4016e
--- /dev/null
@@ -0,0 +1,3 @@
+echo foo | bzip2 >foo.bz2
+busybox bzcat foo.bz2
+test -f foo.bz2