summaryrefslogtreecommitdiffstats
path: root/usr.bin/gzip
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2007-05-28 08:20:46 +0000
committerdelphij <delphij@FreeBSD.org>2007-05-28 08:20:46 +0000
commit23ad5197dd8c2ca2418d4e396d98f82c5d1d184c (patch)
tree278a1d9ff639b2f629c00104baebc0566e404add /usr.bin/gzip
parent1e65a8c94586276c8037349ffacbdc579b87ff7f (diff)
downloadFreeBSD-src-23ad5197dd8c2ca2418d4e396d98f82c5d1d184c.zip
FreeBSD-src-23ad5197dd8c2ca2418d4e396d98f82c5d1d184c.tar.gz
Add a '-k' flag which is similar with its bzip2(1) counterpart,
meaning that the user wants the input file to be left intact. Feature request: Ighighi <ighighi gmail.com> PR: bin/103006 MFC after: 1 month
Diffstat (limited to 'usr.bin/gzip')
-rw-r--r--usr.bin/gzip/gzip.17
-rw-r--r--usr.bin/gzip/gzip.c12
2 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/gzip/gzip.1 b/usr.bin/gzip/gzip.1
index 16d715d..8aea189 100644
--- a/usr.bin/gzip/gzip.1
+++ b/usr.bin/gzip/gzip.1
@@ -27,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
-.Dd March 16, 2007
+.Dd May 28, 2007
.Dt GZIP 1
.Os
.Sh NAME
@@ -35,7 +35,7 @@
.Nd compression/decompression tool using Lempel-Ziv coding (LZ77)
.Sh SYNOPSIS
.Nm
-.Op Fl cdfhLlNnqrtVv
+.Op Fl cdfhkLlNnqrtVv
.Op Fl S Ar suffix
.Ar file
.Oo
@@ -124,6 +124,9 @@ with the
option, allowing non-compressed data to pass through unchanged.
.It Fl h , -help
This option prints a usage summary and exits.
+.It Fl k , -keep
+Keep (don't delete) input files during compression
+or decompression.
.It Fl L , -license
This option prints
.Nm
diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c
index 6f202c7..a3a2a91 100644
--- a/usr.bin/gzip/gzip.c
+++ b/usr.bin/gzip/gzip.c
@@ -143,7 +143,7 @@ static suffixes_t suffixes[] = {
};
#define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0])
-static const char gzip_version[] = "FreeBSD gzip 20070126";
+static const char gzip_version[] = "FreeBSD gzip 20070528";
#ifndef SMALL
static const char gzip_copyright[] = \
@@ -181,6 +181,7 @@ static int numflag = 6; /* gzip -1..-9 value */
#ifndef SMALL
static int fflag; /* force mode */
+static int kflag; /* don't delete input files */
static int nflag; /* don't save name/timestamp */
static int Nflag; /* don't restore name/timestamp */
static int qflag; /* quiet mode */
@@ -261,6 +262,7 @@ static const struct option longopts[] = {
{ "uncompress", no_argument, 0, 'd' },
{ "force", no_argument, 0, 'f' },
{ "help", no_argument, 0, 'h' },
+ { "keep", no_argument, 0, 'k' },
{ "list", no_argument, 0, 'l' },
{ "no-name", no_argument, 0, 'n' },
{ "name", no_argument, 0, 'N' },
@@ -308,7 +310,7 @@ main(int argc, char **argv)
#ifdef SMALL
#define OPT_LIST "123456789cdhltV"
#else
-#define OPT_LIST "123456789acdfhlLNnqrS:tVv"
+#define OPT_LIST "123456789acdfhklLNnqrS:tVv"
#endif
while ((ch = getopt_long(argc, argv, OPT_LIST, longopts, NULL)) != -1) {
@@ -338,6 +340,9 @@ main(int argc, char **argv)
case 'f':
fflag = 1;
break;
+ case 'k':
+ kflag = 1;
+ break;
case 'L':
display_license();
/* NOT REACHED */
@@ -1139,6 +1144,8 @@ unlink_input(const char *file, const struct stat *sb)
{
struct stat nsb;
+ if (kflag)
+ return;
if (stat(file, &nsb) != 0)
/* Must be gone alrady */
return;
@@ -1985,6 +1992,7 @@ usage(void)
" --uncompress\n"
" -f --force force overwriting & compress links\n"
" -h --help display this help\n"
+ " -k --keep don't delete input files during operation\n"
" -l --list list compressed file contents\n"
" -N --name save or restore original file name and time stamp\n"
" -n --no-name don't save original file name or time stamp\n"
OpenPOWER on IntegriCloud