Subject: Re: gzip: fix to wording with -v and -k options

From: Paul Eggert <[email-masked]>
Date: Mon, 10 Nov 2014 11:08:45 -0800

Thanks, I installed the attached patch and am marking this as done.
>From 6ff80bfd55f6308be56014a3b4f00400d8a35023 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Mon, 10 Nov 2014 11:02:38 -0800
Subject: [PATCH] gzip: adjust -v output when -k is also specified

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       | 3 +++
 gzip.c     | 6 +++---
 tests/keep | 7 +++++++
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 3965dd3..643987c 100644
--- 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 713a1c7..1d46cba 100644
--- 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");
     }
 }
diff --git a/tests/keep b/tests/keep
index ea6f667..e2ac5fa 100755
--- a/tests/keep
+++ b/tests/keep
@@ -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
-- 
1.9.3