diff options
author | delphij <delphij@FreeBSD.org> | 2007-05-28 08:20:46 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2007-05-28 08:20:46 +0000 |
commit | 23ad5197dd8c2ca2418d4e396d98f82c5d1d184c (patch) | |
tree | 278a1d9ff639b2f629c00104baebc0566e404add /usr.bin/gzip/gzip.c | |
parent | 1e65a8c94586276c8037349ffacbdc579b87ff7f (diff) | |
download | FreeBSD-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/gzip.c')
-rw-r--r-- | usr.bin/gzip/gzip.c | 12 |
1 files changed, 10 insertions, 2 deletions
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" |