On Thu, Mar 03 2022, Todd C. Miller <[email protected]> wrote:
> On Thu, 03 Mar 2022 15:11:13 +0000, Miod Vallat wrote:
>
>> > I think this makes sense if only for better GNU gzip compatibility.
>> > OK millert@
>>
>> But does the `-k' flag needs to be added to compress(1) too?
>
> No, it just makes usage() slightly more complicated.
> But that diff was missing an update to usage() anyway.
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.
> Index: compress.1
> ===================================================================
> RCS file: /home/reposync/src/usr.bin/compress/compress.1,v
> retrieving revision 1.48
> diff -u -p -r1.48 compress.1
> --- compress.1 17 Mar 2014 14:23:50 -0000 1.48
> +++ compress.1 3 Mar 2022 12:08:01 -0000
> @@ -44,13 +44,13 @@
> .Nd compress and expand data (compress mode)
> .Sh SYNOPSIS
> .Nm compress
> -.Op Fl 123456789cdfghlNnOqrtv
> +.Op Fl 123456789cdfghklNnOqrtv
> .Op Fl b Ar bits
> .Op Fl o Ar filename
> .Op Fl S Ar suffix
> .Op Ar
> .Nm uncompress
> -.Op Fl cfhlNnqrtv
> +.Op Fl cfhklNnqrtv
> .Op Fl o Ar filename
> .Op Ar
> .Nm zcat
> @@ -192,6 +192,8 @@ Use the deflate scheme, which reportedly
> mode).
> .It Fl h
> Print a short help message.
> +.It Fl k
> +Keep input files after compression or decompression.
> .It Fl l
> List information for the specified compressed files.
> The following information is listed:
> 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 -0000 1.14
> +++ gzip.1 3 Mar 2022 12:08:21 -0000
> @@ -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 -0000 1.98
> +++ main.c 3 Mar 2022 12:00:28 -0000
> @@ -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,
> @@ -92,8 +92,8 @@ const struct compressor {
> "compress",
> ".Z",
> "\037\235",
> - "123456789ab:cdfghlNnOo:qrS:tv",
> - "cfhlNno:qrtv",
> + "123456789ab:cdfghklNnOo:qrS:tv",
> + "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;
>
>
>
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE