]> git.cworth.org Git - gzip/blobdiff - gzip.c
Imported Debian patch 1.3.5-14
[gzip] / gzip.c
diff --git a/gzip.c b/gzip.c
index 2f692b5658327d6e33ee21abcfe0ce53709a9647..bfab6e74b96f0e0f7a55a558a8c247b9cd14f914 100644 (file)
--- a/gzip.c
+++ b/gzip.c
@@ -882,10 +882,21 @@ local void treat_file(iname)
 
     close(ifd);
     if (!to_stdout) {
-         /* Copy modes, times, ownership, and remove the input file */
+         /* Copy modes, times, and ownership */
          copy_stat(&istat);
          if (close(ofd))
             write_error();
+         remove_ofname = 0;
+
+         /* It's now safe to remove the input file: */
+         if (xunlink (ifname)) {
+           int e = errno;
+           WARN((stderr, "%s: ", progname));
+           if (!quiet) {
+             errno = e;
+             perror(ifname);
+           }
+         }
     }
     if (method == -1) {
        if (!to_stdout) xunlink (ofname);
@@ -1169,8 +1180,9 @@ local int make_ofname()
     } else if (suff != NULL) {
        /* Avoid annoying messages with -r (see treat_dir()) */
        if (verbose || (!recursive && !quiet)) {
-           WARN((stderr, "%s: %s already has %s suffix -- unchanged\n",
-                 progname, ifname, suff));
+           /* don't use WARN -- it will cause an exit_code of 2 */
+           fprintf(stderr, "%s: %s already has %s suffix -- unchanged\n",
+                 progname, ifname, suff);
        }
        return WARNING;
     } else {
@@ -1744,16 +1756,6 @@ local void copy_stat(ifstat)
 #ifndef NO_CHOWN
     fchown(ofd, ifstat->st_uid, ifstat->st_gid);  /* Copy ownership */
 #endif
-    remove_ofname = 0;
-    /* It's now safe to remove the input file: */
-    if (xunlink (ifname)) {
-       int e = errno;
-       WARN((stderr, "%s: ", progname));
-       if (!quiet) {
-           errno = e;
-           perror(ifname);
-       }
-    }
 }
 
 #if ! NO_DIR