gzip: adjust -v output when -k is also specified
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 10 Nov 2014 19:02:38 +0000 (11:02 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 10 Nov 2014 19:03:15 +0000 (11:03 -0800)
Problem reported by Eric Benoit in: http://bugs.gnu.org/16401
* gzip.c (treat_file): When keeping a file, don't say it's replaced.
* NEWS: Document this.
* tests/keep: Test this.

NEWS
gzip.c
tests/keep

diff --git a/NEWS b/NEWS
index 3965dd3afb8fe6ce840767bb686f8b4242b8ceef..643987c6e6fd255983d01abaf96ce14da818bf6c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,9 @@ GNU gzip NEWS                                    -*- outline -*-
   on some platforms when compiled with optimization.
   [bug introduced in gzip-1.3.6]
 
+  gzip -k -v no longer reports that files are replaced.
+  [bug present since the beginning]
+
   zgrep no longer malfunctions with a multi-digit context option like -15.
   Now, it passes that option to grep (equivalent to -C15) just as it does
   for single-digit options. [bug introduced in gzip-1.3.12]
diff --git a/gzip.c b/gzip.c
index 713a1c75a4b8fb78ba027fa71338533878a0cf5c..1d46cba3ac3558593e4a756ee58d709c6a16fbf5 100644 (file)
--- a/gzip.c
+++ b/gzip.c
@@ -898,9 +898,9 @@ local void treat_file(iname)
         } else {
             display_ratio(bytes_in-(bytes_out-header_bytes), bytes_in, stderr);
         }
-        if (!test && !to_stdout) {
-            fprintf(stderr, " -- replaced with %s", ofname);
-        }
+        if (!test && !to_stdout)
+          fprintf(stderr, " -- %s %s", keep ? "created" : "replaced with",
+                  ofname);
         fprintf(stderr, "\n");
     }
 }
index ea6f667149a5ec317314a12f1265a9a0f991ed94..e2ac5fa254b2eaf6f1967c5c15b3c37a5623df08 100755 (executable)
@@ -41,4 +41,11 @@ for k in --keep ''; do
   rm -f in.gz || fail=1
 done
 
+cp orig in || framework_failure_
+log=$(gzip -kv in 2>&1) || fail=1
+case $log in
+  *'created in.gz'*) ;;
+  *) fail=1;;
+esac
+
 Exit $fail