Hi, As inspired by bin/103006, I have added an '-k' option for our BSD gzip, as in attachment. The -k option acts like bzip2(1)'s counterpart which requests gzip(1) to keep the file (instead of the default behavior, delete it). Comments? (A bsdgzip version backported to RELENG_6 can be obtained from http://people.freebsd.org/~delphij/gzip-r6/gzip.tbz ) Cheers, -- Xin LI <delphij_at_delphij.net> http://www.delphij.net/ FreeBSD - The Power to Serve! Index: gzip.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/gzip/gzip.1,v retrieving revision 1.1 diff -u -p -u -r1.1 gzip.1 --- gzip.1 26 Jan 2007 10:19:07 -0000 1.1 +++ gzip.1 31 Jan 2007 06:39:38 -0000 _at__at_ -27,7 +27,7 _at__at_ .\" SUCH DAMAGE. .\" .\" $FreeBSD: src/usr.bin/gzip/gzip.1,v 1.1 2007/01/26 10:19:07 delphij Exp $ -.Dd January 26, 2007 +.Dd January 31, 2007 .Dt GZIP 1 .Os .Sh NAME _at__at_ -35,7 +35,7 _at__at_ .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 _at__at_ -43,7 +43,7 _at__at_ .Oc .Oc .Nm gunzip -.Op Fl cfhLNqrtVv +.Op Fl cfhkLNqrtVv .Op Fl S Ar suffix .Ar file .Oo _at__at_ -124,6 +124,8 _at__at_ 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 Index: gzip.c =================================================================== RCS file: /home/ncvs/src/usr.bin/gzip/gzip.c,v retrieving revision 1.1 diff -u -p -u -r1.1 gzip.c --- gzip.c 26 Jan 2007 10:19:07 -0000 1.1 +++ gzip.c 31 Jan 2007 06:36:42 -0000 _at__at_ -143,7 +143,7 _at__at_ 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 20070131"; #ifndef SMALL static const char gzip_copyright[] = \ _at__at_ -181,6 +181,7 _at__at_ static int numflag = 6; /* gzip -1..-9 #ifndef SMALL static int fflag; /* force mode */ +static int kflag; /* keep input file? */ static int nflag; /* don't save name/timestamp */ static int Nflag; /* don't restore name/timestamp */ static int qflag; /* quiet mode */ _at__at_ -261,6 +262,7 _at__at_ 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' }, _at__at_ -308,7 +310,7 _at__at_ 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) { _at__at_ -338,6 +340,9 _at__at_ main(int argc, char **argv) case 'f': fflag = 1; break; + case 'k': + kflag = 1; + break; case 'L': display_license(); /* NOT REACHED */ _at__at_ -1145,6 +1150,10 _at__at_ unlink_input(const char *file, const str if (nsb.st_dev != sb->st_dev || nsb.st_ino != sb->st_ino) /* Definitely a different file */ return; +#ifndef SMALL + if (kflag) + return; +#endif unlink(file); } #endif _at__at_ -1985,6 +1994,7 _at__at_ usage(void) " --uncompress\n" " -f --force force overwriting & compress links\n" " -h --help display this help\n" + " -k --keep keep input files during compression or decompression\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"
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:05 UTC