Subject: bug#16401: closed (Re: gzip: fix to wording with -v and -k options)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 10 Nov 2014 19:09:02 +0000

Your bug report

#16401: gzip: fix to wording with -v and -k options

which was filed against the gzip package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
16401: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16401
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: gzip: fix to wording with -v and -k options
From: Paul Eggert <[email-masked]>
To: [email-masked]
Date: Mon, 10 Nov 2014 11:08:45 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

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

Subject: gzip: fix to wording with -v and -k options
From: Eric Benoit <[email-masked]>
To: [email-masked]
Date: Wed, 08 Jan 2014 12:42:26 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

I noticed that with gzip when using both the -v and -k options, the
associated wording doesn't correctly reflect the action of the -k (keep)
option.

I've attached a trivial patch (against gzip 1.6) to correctly
distinguish between having this option set or not.

Thanks
diff -ru gzip-1.6/gzip.c gzip-1.6.new/gzip.c
--- gzip-1.6/gzip.c	2013-05-28 09:25:19.000000000 -0400
+++ gzip-1.6.new/gzip.c	2014-01-08 12:20:04.443394993 -0500
@@ -899,7 +899,11 @@
             display_ratio(bytes_in-(bytes_out-header_bytes), bytes_in, stderr);
         }
         if (!test && !to_stdout) {
-            fprintf(stderr, " -- replaced with %s", ofname);
+            if (!keep) {
+                fprintf(stderr, " -- replaced with %s", ofname);
+            } else {
+                fprintf(stderr, " -- created %s", ofname);
+            }
         }
         fprintf(stderr, "\n");
     }