On Sat, 05 Mar 2022 19:15:02 -0700
"Todd C. Miller" :
> On Sun, 06 Mar 2022 02:58:30 +0100, Jeremie Courreges-Anglas wrote:
>
> > I'm not sure what you mean here. Solene's diff added -k to both
> > compress(1) and gzip(1) (and their uncompressor counterparts).
> > Adding -k to gzip/gunzip only would indeed make the usage() slightly
> > more complicated.
> >
> > So do we want to add -k to compress(1) or not? (No strong opinion.)
> >
> > I like the general idea and the diff seems to work as intended.
>
> I don't really care whether or not we add -k to compress(1). However,
> since other versions of compress do not have a -k option it is
> probably best to avoiding adding it.
>
> - todd
here is a new version that doesn't add -k to compress and uncompress
gzip -k and gunzip -k works as expected
compress -k and uncompress -k will display unknown option -- k and
show the usage that doesn't show k flag
Index: gzip.1
===
RCS file: /home/reposync/src/usr.bin/compress/gzip.1,v
retrieving revision 1.14
diff -u -p -r1.14 gzip.1
--- gzip.1 7 Oct 2014 21:06:30 - 1.14
+++ gzip.1 3 Mar 2022 12:08:21 -
@@ -43,13 +43,13 @@
.Nd compress and expand data (deflate mode)
.Sh SYNOPSIS
.Nm gzip
-.Op Fl 123456789cdfhLlNnOqrtVv
+.Op Fl 123456789cdfhkLlNnOqrtVv
.Op Fl b Ar bits
.Op Fl o Ar filename
.Op Fl S Ar suffix
.Op Ar
.Nm gunzip
-.Op Fl cfhLlNnqrtVv
+.Op Fl cfhkLlNnqrtVv
.Op Fl o Ar filename
.Op Ar
.Nm gzcat
@@ -183,6 +183,8 @@ behave as
.Xr cat 1 .
.It Fl h
Print a short help message.
+.It Fl k
+Keep input files after compression or decompression.
.It Fl L
A no-op which exists for compatibility only.
On GNU gzip, it displays the program's license.
Index: main.c
===
RCS file: /home/reposync/src/usr.bin/compress/main.c,v
retrieving revision 1.98
diff -u -p -r1.98 main.c
--- main.c 18 Jan 2021 00:46:58 - 1.98
+++ main.c 12 Mar 2022 14:43:18 -
@@ -75,8 +75,8 @@ const struct compressor {
"deflate",
".gz",
"\037\213",
- "123456789ab:cdfhLlNnOo:qrS:tVv",
- "cfhLlNno:qrtVv",
+ "123456789ab:cdfhkLlNnOo:qrS:tVv",
+ "cfhkLlNno:qrtVv",
"fhqr",
gz_ropen,
gz_read,
@@ -93,7 +93,7 @@ const struct compressor {
".Z",
"\037\235",
"123456789ab:cdfghlNnOo:qrS:tv",
- "cfhlNno:qrtv",
+ "cfhklNno:qrtv",
"fghqr",
z_ropen,
zread,
@@ -110,8 +110,8 @@ const struct compressor null_method = {
"null",
".nul",
"XX",
- "123456789ab:cdfghlNnOo:qrS:tv",
- "cfhlNno:qrtv",
+ "123456789ab:cdfghklNnOo:qrS:tv",
+ "cfhklNno:qrtv",
"fghqr",
null_ropen,
null_read,
@@ -141,6 +141,7 @@ 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' },
{ "license",no_argument,0, 'L' },
{ "no-name",no_argument,0, 'n' },
@@ -166,12 +167,12 @@ main(int argc, char *argv[])
const char *optstr, *s;
char *p, *infile;
char outfile[PATH_MAX], _infile[PATH_MAX], suffix[16];
- int bits, ch, error, rc, cflag, oflag;
+ int bits, ch, error, rc, cflag, oflag, kflag;
if (pledge("stdio rpath wpath cpath fattr chown", NULL) == -1)
err(1, "pledge");
- bits = cflag = oflag = 0;
+ bits = cflag = oflag = kflag = 0;
storename = -1;
p = __progname;
if (p[0] == 'g') {
@@ -276,6 +277,9 @@ main(int argc, char *argv[])
strlcpy(suffix, method->suffix, sizeof(suffix));
bits = 6;
break;
+ case 'k':
+ kflag = 1;
+ break;
case 'l':
list++;
testmode = 1;
@@ -459,7 +463,7 @@ main(int argc, char *argv[])
switch (error) {
case SUCCESS:
if (!cat && !testmode) {
- if (!pipin && unlink(infile) && verbose >= 0)
+ if (!pipin && !kflag && unlink(infile) &&
verbose >= 0)
warn("input: %s", infile);
}
break;