[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] gzip: add "--keep" option to keep original files unchanged
From: |
Rodrigo Campos |
Subject: |
[PATCH] gzip: add "--keep" option to keep original files unchanged |
Date: |
Sat, 9 Feb 2013 14:51:59 -0300 |
By default it is disabled to keep everything working as before. And as a
shortcut "-K", instead of "-k", is used to avoid overlapping with pkzip
(although pkzip is not being used right now)
Also, this patch changes "--stdout" which "Write output on standard output; keep
original files unchanged" to imply "-K"
---
gzip.1 | 9 ++++++---
gzip.c | 11 ++++++++---
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/gzip.1 b/gzip.1
index c97aeb1..addd253 100644
--- a/gzip.1
+++ b/gzip.1
@@ -4,7 +4,7 @@ gzip, gunzip, zcat \- compress or expand files
.SH SYNOPSIS
.ll +8
.B gzip
-.RB [ " \-acdfhlLnNrtvV19 " ]
+.RB [ " \-acdfhKlLnNrtvV19 " ]
.RB [ \-S\ suffix ]
[
.I "name \&..."
@@ -12,7 +12,7 @@ gzip, gunzip, zcat \- compress or expand files
.ll -8
.br
.B gunzip
-.RB [ " \-acfhlLnNrtvV " ]
+.RB [ " \-acfhKlLnNrtvV " ]
.RB [ \-S\ suffix ]
[
.I "name \&..."
@@ -218,6 +218,9 @@ prompts to verify whether an existing file should be
overwritten.
.B \-h --help
Display a help screen and quit.
.TP
+.B \-K --keep
+Keep original files unchanged.
+.TP
.B \-l --list
For each compressed file, list the following fields:
@@ -392,7 +395,7 @@ Internet RFC 1951 (May 1996).
Exit status is normally 0;
if an error occurs, exit status is 1. If a warning occurs, exit status is 2.
.TP
-Usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
+Usage: gzip [-cdfhKlLnNrtvV19] [-S suffix] [file ...]
Invalid options were specified on the command line.
.TP
\fIfile\fP\^: not in gzip format
diff --git a/gzip.c b/gzip.c
index 66529e0..b568c2c 100644
--- a/gzip.c
+++ b/gzip.c
@@ -167,6 +167,7 @@ static int ascii = 0; /* convert end-of-lines to
local OS conventions */
int to_stdout = 0; /* output to stdout (-c) */
static int decompress = 0; /* decompress (-d) */
static int force = 0; /* don't ask questions, compress links (-f) */
+static int keep = 0; /* keep original files unchanged */
static int no_name = -1; /* don't save or restore the original file name */
static int no_time = -1; /* don't save or restore the original file time */
static int recursive = 0; /* recurse through directories (-r) */
@@ -256,6 +257,7 @@ static const struct option longopts[] =
{"force", 0, 0, 'f'}, /* force overwrite of output file */
{"help", 0, 0, 'h'}, /* give help */
/* {"pkzip", 0, 0, 'k'}, force output in pkzip format */
+ {"keep", 0, 0, 'K'}, /* keep original files unchanged */
{"list", 0, 0, 'l'}, /* list .gz file contents */
{"license", 0, 0, 'L'}, /* display software license */
{"no-name", 0, 0, 'n'}, /* don't save or restore original name & time */
@@ -334,6 +336,7 @@ local void help()
" -f, --force force overwrite of output file and compress links",
" -h, --help give this help",
/* -k, --pkzip force output in pkzip format */
+ " -K, --keep keep original files unchanged",
" -l, --list list compressed file contents",
" -L, --license display software license",
#ifdef UNDOCUMENTED
@@ -437,7 +440,7 @@ int main (int argc, char **argv)
z_suffix = Z_SUFFIX;
z_len = strlen(z_suffix);
- while ((optc = getopt_long (argc, argv, "ab:cdfhH?lLmMnNqrS:tvVZ123456789",
+ while ((optc = getopt_long (argc, argv,
"ab:cdfhH?KlLmMnNqrS:tvVZ123456789",
longopts, (int *)0)) != -1) {
switch (optc) {
case 'a':
@@ -453,13 +456,15 @@ int main (int argc, char **argv)
}
break;
case 'c':
- to_stdout = 1; break;
+ to_stdout = keep = 1; break;
case 'd':
decompress = 1; break;
case 'f':
force++; break;
case 'h': case 'H':
help(); do_exit(OK); break;
+ case 'K':
+ keep = 1; break;
case 'l':
list = decompress = to_stdout = 1; break;
case 'L':
@@ -849,7 +854,7 @@ local void treat_file(iname)
if (close (ifd) != 0)
read_error ();
- if (!to_stdout)
+ if (!keep)
{
sigset_t oldset;
int unlink_errno;
--
1.7.10.4
- gzip: add "--keep" option to keep original files unchanged, Rodrigo Campos, 2013/02/09
- [PATCH] gzip: add "--keep" option to keep original files unchanged, Rodrigo Campos, 2013/02/09
- [PATCH] gzip: add "--keep" option to keep original files unchanged,
Rodrigo Campos <=
- Re: gzip: add "--keep" option to keep original files unchanged, Paul Eggert, 2013/02/09
- Re: gzip: add "--keep" option to keep original files unchanged, Antonio Diaz Diaz, 2013/02/09
- Re: gzip: add "--keep" option to keep original files unchanged, Rodrigo Campos, 2013/02/10
- Re: gzip: add "--keep" option to keep original files unchanged, Paul Eggert, 2013/02/10
- Re: gzip: add "--keep" option to keep original files unchanged, Eric Blake, 2013/02/11
- Re: gzip: add "--keep" option to keep original files unchanged, Rodrigo Campos, 2013/02/11
- Re: gzip: add "--keep" option to keep original files unchanged, Rodrigo Campos, 2013/02/12
- Re: gzip: add "--keep" option to keep original files unchanged, Paul Eggert, 2013/02/12
- Re: gzip: add "--keep" option to keep original files unchanged, Rodrigo Campos, 2013/02/12
- Re: gzip: add "--keep" option to keep original files unchanged, Bob Proulx, 2013/02/12