Package: gzip Version: 1.3.12 bzip2 gives a -k or --keep option which prevents the source files from being deleted. gzip does not have this. It is highly useful when a number of files have to be compressed/decompressed. Otherwise we are forced to write a for x in $(ls *.gz) kind of script when just two letters "-k" will solve the problem.
I created a patch for this. Shriramana Sharma.
--- gzip.c.orig 2007-03-20 10:39:51.000000000 +0530 +++ gzip.c 2007-04-15 17:32:43.000000000 +0530 @@ -189,6 +189,7 @@ int recursive = 0; /* recurse through directories (-r) */ int list = 0; /* list the file contents (-l) */ int verbose = 0; /* be verbose (-v) */ +int keep_input_files = 0; /* do not delete input files */ int quiet = 0; /* be very quiet (-q) */ int do_lzw = 0; /* generate output compatible with old compress (-Z) */ int test = 0; /* test .gz file integrity */ @@ -243,7 +244,8 @@ /* {"encrypt", 0, 0, 'e'}, encrypt */ {"force", 0, 0, 'f'}, /* force overwrite of output file */ {"help", 0, 0, 'h'}, /* give help */ - /* {"pkzip", 0, 0, 'k'}, force output in pkzip format */ + /* {"pkzip", 0, 0, 'k'}, force output in pkzip format */ /* IF THIS IS ENABLED IT WILL CONFLICT WITH "KEEP" */ + {"keep", 0, 0, 'k'}, /* keep input files */ {"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 */ @@ -318,7 +320,8 @@ /* -e, --encrypt encrypt */ " -f, --force force overwrite of output file and compress links", " -h, --help give this help", -/* -k, --pkzip force output in pkzip format */ +/* -k, --pkzip force output in pkzip format */ /* IF THIS IS ENABLED IT WILL CONFLICT WITH "KEEP" */ + " -k, --keep keep (don't delete) input files", " -l, --list list compressed file contents", " -L, --license display software license", #ifdef UNDOCUMENTED @@ -417,13 +420,13 @@ decompress = 1; else if (strequ (program_name + 1, "cat") /* zcat, pcat, gcat */ || strequ (program_name, "gzcat")) /* gzcat */ - decompress = to_stdout = 1; + decompress = to_stdout = keep_input_files = 1; #endif 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': @@ -439,15 +442,17 @@ } break; case 'c': - to_stdout = 1; break; + to_stdout = keep_input_files = 1; break; case 'd': decompress = 1; break; + case 'k': + keep_input_files = 1; break; case 'f': force++; break; case 'h': case 'H': help(); do_exit(OK); break; case 'l': - list = decompress = to_stdout = 1; break; + list = decompress = to_stdout = keep_input_files = 1; break; case 'L': license(); do_exit(OK); break; case 'm': /* undocumented, may change later */ @@ -477,7 +482,7 @@ z_suffix = optarg; break; case 't': - test = decompress = to_stdout = 1; + test = decompress = to_stdout = keep_input_files = 1; break; case 'v': verbose++; quiet = 0; break; @@ -701,7 +706,7 @@ return; } - if (! to_stdout) + if (! keep_input_files) { if (! S_ISREG (istat.st_mode)) { @@ -822,12 +827,13 @@ if (close (ifd) != 0) read_error (); - if (!to_stdout) + if (!to_stdout) copy_stat (&istat); + + if (!keep_input_files) { sigset_t oldset; int unlink_errno; - copy_stat (&istat); if (close (ofd) != 0) write_error ();