Paul Eggert <eggert@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at submit) by debbugs.gnu.org; 11 Feb 2025 07:23:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 11 02:23:08 2025 Received: from localhost ([127.0.0.1]:53976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1thkbr-0002TW-Ik for submit <at> debbugs.gnu.org; Tue, 11 Feb 2025 02:23:08 -0500 Received: from lists.gnu.org ([2001:470:142::17]:37314) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eggert@HIDDEN>) id 1thkbo-0002SH-J1 for submit <at> debbugs.gnu.org; Tue, 11 Feb 2025 02:23:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eggert@HIDDEN>) id 1thkbh-0007RJ-3W for bug-gzip@HIDDEN; Tue, 11 Feb 2025 02:22:57 -0500 Received: from mail.cs.ucla.edu ([131.179.128.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eggert@HIDDEN>) id 1thkbd-0002pS-FZ for bug-gzip@HIDDEN; Tue, 11 Feb 2025 02:22:56 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 647413C00517E for <bug-gzip@HIDDEN>; Mon, 10 Feb 2025 23:22:49 -0800 (PST) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id hbgfteMJfqCZ; Mon, 10 Feb 2025 23:22:48 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id B27333C00517D; Mon, 10 Feb 2025 23:22:48 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu B27333C00517D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1739258568; bh=Xb7fKK3mdBHsJvOYAlfhyAgOZsgeOmR5SgmF/EP+xaA=; h=From:To:Date:Message-ID:MIME-Version; b=gqGYVQx9ZFeI4MYWr2u9GUkJOfrRsNCO9buMsGw9xWp2ms6b7T/+Wfjb/Lvnsa752 A5/LTPkv28Vw3zLfFseyAYCXyCJlGUqf6a9CnWlCPB15i1qYg/+NCw/1nYha3BaTl+ hY8tg/x3p9PVY/hmdjZJuUrWK2aHfvYtlDK4bhqi7DyABFfj2zHjTqJIl8scFktpWv IPJy5VG78MSsGKG0kK6+K/F1HC7u6JDC8XL9AnbLfSEoNCYiHQ5HOrcddtkOGFIa5C 5YesfG/KgeKfw2Gq8x1GwcyWPG9xrCLiK3y5104GuYUl4wLOZ4vz3JczXz6cooQqvE Llw6oCg6MZFAQ== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id iaY1_XdCWumc; Mon, 10 Feb 2025 23:22:48 -0800 (PST) Received: from wing.home (unknown [47.154.28.214]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id 9A7C83C011BE0; Mon, 10 Feb 2025 23:22:48 -0800 (PST) From: Paul Eggert <eggert@HIDDEN> To: bug-gzip@HIDDEN Subject: [PROPOSED] gzip: drop support for the GZIP env var Date: Mon, 10 Feb 2025 23:22:34 -0800 Message-ID: <20250211072241.854108-1-eggert@HIDDEN> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=131.179.128.66; envelope-from=eggert@HIDDEN; helo=mail.cs.ucla.edu X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: Paul Eggert <eggert@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) The GZIP environment variable is too hazardous. * gzip.c (env, ENV_OPTION): * tailor.h (OPTIONS_VAR): * util.c (SEPARATOR, add_envopt): Remove. All uses removed. * gzip.c (main): Ignore GZIP. * tests/gzip-env: Test that GZIP is ignored. --- NEWS | 6 ++++ doc/gzip.texi | 11 ++----- gzip.1 | 18 ++++-------- gzip.c | 79 +------------------------------------------------- gzip.h | 1 - tailor.h | 4 --- tests/gzip-env | 19 +++++------- util.c | 60 -------------------------------------- znew.in | 2 +- 9 files changed, 24 insertions(+), 176 deletions(-) diff --git a/NEWS b/NEWS index e348355..0c4a2fc 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,12 @@ GNU gzip NEWS -*- out= line -*- =20 * Noteworthy changes in release ?.? (????-??-??) [?] =20 +** Changes in behavior + + The GZIP environment variable, which was marked as obsolescent in + gzip 1.7 (2016) due to its hazards, has been removed. You can use + an alias or script instead. + ** Bug fixes =20 'gzip -d' no longer omits the last partial output buffer when the diff --git a/doc/gzip.texi b/doc/gzip.texi index cc05b60..1bfca98 100644 --- a/doc/gzip.texi +++ b/doc/gzip.texi @@ -487,14 +487,9 @@ complement to @command{tar}, not as a replacement. @chapter Environment @cindex Environment =20 -The obsolescent environment variable @env{GZIP} can hold a set of -default options for @command{gzip}. These options are interpreted -first and can be overwritten by explicit command line parameters. As -this can cause problems when using scripts, this feature is supported -only for options that are reasonably likely to not cause too much -harm, and @command{gzip} warns if it is used. This feature will be -removed in a future release of @command{gzip}. - +Although previous verions of @command{gzip} examined the environment +variable @env{GZIP} for a set of default options, +this feature has been removed because it caused problems when using scri= pts. You can use an alias or script instead. For example, if @command{gzip} is in the directory @samp{/usr/bin} you can prepend @file{$HOME/bin} to your @env{PATH} and create an executable script diff --git a/gzip.1 b/gzip.1 index 0efe399..4afa243 100644 --- a/gzip.1 +++ b/gzip.1 @@ -416,20 +416,12 @@ such as tar or zip. GNU tar supports the \-z option to invoke gzip transparently. gzip is designed as a complement to tar, not as a replacement. .SH "ENVIRONMENT" -The obsolescent environment variable -.B GZIP -can hold a set of default options for -.BR gzip . -These options are interpreted first and can be overwritten by explicit -command line parameters. -As this can cause problems when using scripts, -this feature is supported only for options that are -reasonably likely to not cause too much harm, and +Although previous versions of .B gzip -warns if it is used. -This feature will be removed in a future release of -.BR gzip . -.PP +examined the environment variable +.B GZIP +for a set of default options, this feature has been removed +because it caused problems when using scripts. You can use an alias or script instead. For example, if .B gzip diff --git a/gzip.c b/gzip.c index a33841a..1fe589b 100644 --- a/gzip.c +++ b/gzip.c @@ -182,7 +182,6 @@ static int foreground =3D 0; /* set if program run = in foreground */ static int last_member; /* set for .zip and .Z files */ static int part_nb; /* number of parts in .gz file */ off_t ifile_size; /* input file size, -1 for devices (debug = only) */ -static char *env; /* contents of GZIP env variable */ static char const *z_suffix; /* default suffix (can be set with --suffix= ) */ static size_t z_len; /* strlen(z_suffix) */ =20 @@ -249,10 +248,6 @@ enum PRESUME_INPUT_TTY_OPTION =3D CHAR_MAX + 1, RSYNCABLE_OPTION, SYNCHRONOUS_OPTION, - - /* A value greater than all valid long options, used as a flag to - distinguish options derived from the GZIP environment variable. */ - ENV_OPTION }; =20 static char const shortopts[] =3D "ab:cdfhH?klLmMnNqrS:tvVZ123456789"; @@ -413,9 +408,6 @@ int main (int argc, char **argv) { int file_count; /* number of files to process */ size_t proglen; /* length of program_name */ - char **argv_copy; - int env_argc; - char **env_argv; =20 EXPAND(argc, argv); /* wild card expansion if necessary */ =20 @@ -426,11 +418,6 @@ int main (int argc, char **argv) if (4 < proglen && strequ (program_name + proglen - 4, ".exe")) program_name[proglen - 4] =3D '\0'; =20 - /* Add options in GZIP environment variable if there is one */ - argv_copy =3D argv; - env =3D add_envopt (&env_argc, &argv_copy, OPTIONS_VAR); - env_argv =3D env ? argv_copy : NULL; - #ifndef GNU_STANDARD # define GNU_STANDARD 1 #endif @@ -454,49 +441,8 @@ int main (int argc, char **argv) z_len =3D strlen(z_suffix); =20 while (true) { - int optc; int longind =3D -1; - - if (env_argv) - { - if (env_argv[optind] && strequ (env_argv[optind], "--")) - optc =3D ENV_OPTION + '-'; - else - { - optc =3D getopt_long (env_argc, env_argv, shortopts, lon= gopts, - &longind); - if (0 <=3D optc) - optc +=3D ENV_OPTION; - else - { - if (optind !=3D env_argc) - { - fprintf (stderr, - ("%s: %s: non-option in "OPTIONS_VAR - " environment variable\n"), - program_name, env_argv[optind]); - try_help (); - } - - /* Wait until here before warning, so that GZIP=3D'-= q' - doesn't warn. */ - if (env_argc !=3D 1 && !quiet) - fprintf (stderr, - ("%s: warning: "OPTIONS_VAR" environment = variable" - " is deprecated; use an alias or script\= n"), - program_name); - - /* Start processing ARGC and ARGV instead. */ - free (env_argv); - env_argv =3D NULL; - optind =3D 1; - longind =3D -1; - } - } - } - - if (!env_argv) - optc =3D getopt_long (argc, argv, shortopts, longopts, &longin= d); + int optc =3D getopt_long (argc, argv, shortopts, longopts, &long= ind); if (optc < 0) break; =20 @@ -532,15 +478,12 @@ int main (int argc, char **argv) case 'M': /* undocumented, may change later */ no_time =3D 0; break; case 'n': - case 'n' + ENV_OPTION: no_name =3D no_time =3D 1; break; case 'N': - case 'N' + ENV_OPTION: no_name =3D no_time =3D 0; break; case PRESUME_INPUT_TTY_OPTION: presume_input_tty =3D true; break; case 'q': - case 'q' + ENV_OPTION: quiet =3D 1; verbose =3D 0; break; case 'r': #if NO_DIR @@ -553,7 +496,6 @@ int main (int argc, char **argv) break; =20 case RSYNCABLE_OPTION: - case RSYNCABLE_OPTION + ENV_OPTION: rsync =3D 1; break; case 'S': @@ -575,7 +517,6 @@ int main (int argc, char **argv) test =3D decompress =3D to_stdout =3D 1; break; case 'v': - case 'v' + ENV_OPTION: verbose++; quiet =3D 0; break; case 'V': version (); finish_out (); break; @@ -584,28 +525,12 @@ int main (int argc, char **argv) program_name); try_help (); break; - case '1' + ENV_OPTION: case '2' + ENV_OPTION: case '3' + ENV_O= PTION: - case '4' + ENV_OPTION: case '5' + ENV_OPTION: case '6' + ENV_O= PTION: - case '7' + ENV_OPTION: case '8' + ENV_OPTION: case '9' + ENV_O= PTION: - optc -=3D ENV_OPTION; - FALLTHROUGH; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': level =3D optc - '0'; break; =20 default: - if (ENV_OPTION <=3D optc && optc !=3D ENV_OPTION + '?') - { - /* Output a diagnostic, since getopt_long didn't. */ - fprintf (stderr, "%s: ", program_name); - if (longind < 0) - fprintf (stderr, "-%c: ", optc - ENV_OPTION); - else - fprintf (stderr, "--%s: ", longopts[longind].name); - fprintf (stderr, ("option not valid in "OPTIONS_VAR - " environment variable\n")); - } try_help (); } } /* loop on all arguments */ @@ -2042,8 +1967,6 @@ do_exit (int exitcode) =20 if (in_exit) exit(exitcode); in_exit =3D 1; - free(env); - env =3D NULL; FREE(inbuf); FREE(outbuf); FREE(d_buf); diff --git a/gzip.h b/gzip.h index 855a88b..66b504b 100644 --- a/gzip.h +++ b/gzip.h @@ -314,7 +314,6 @@ extern char *strlwr (char *s); extern char *gzip_base_name (char *fname) _GL_ATTRIBUTE_PURE; extern int xunlink (char *fname); extern void make_simple_name (char *name); -extern char *add_envopt (int *argcp, char ***argvp, char const *env); _Noreturn extern void gzip_error (char const *m); _Noreturn extern void xalloc_die (void); extern void warning (char const *m); diff --git a/tailor.h b/tailor.h index c9147b1..095d7ce 100644 --- a/tailor.h +++ b/tailor.h @@ -163,10 +163,6 @@ # define casemap(c) (c) #endif =20 -#ifndef OPTIONS_VAR -# define OPTIONS_VAR "GZIP" -#endif - #ifndef Z_SUFFIX # define Z_SUFFIX ".gz" #endif diff --git a/tests/gzip-env b/tests/gzip-env index b7382d9..2da5915 100755 --- a/tests/gzip-env +++ b/tests/gzip-env @@ -1,5 +1,5 @@ #!/bin/sh -# Test the obsolescent GZIP environment variable. +# Test that gzip is unaffected by the GZIP environment variable. =20 # Copyright 2015-2025 Free Software Foundation, Inc. =20 @@ -23,20 +23,17 @@ echo a >exp || framework_failure_ gzip <exp >in || framework_failure_ =20 fail=3D0 -GZIP=3D-qv gzip -d <in >out 2>err || fail=3D1 -compare exp out || fail=3D1 =20 -for badopt in -- -c --stdout -d --decompress -f --force -h --help -k --k= eep \ +for opt in -qv \ + -- -c --stdout -d --decompress -f --force -h --help -k --keep \ -l --list -L --license -r --recursive -Sxxx --suffix=3Dxxx '--suffix x= xx' \ - -t --test -V --version -do - GZIP=3D$badopt gzip -d <in >out 2>err && fail=3D1 -done - -for goodopt in -n --no-name -N --name -q --quiet -v --verbose \ + -t --test -V --version \ + -n --no-name -N --name -q --quiet -v --verbose \ -1 --fast -2 -3 -4 -5 -6 -7 -8 -9 --best do - GZIP=3D$goodopt gzip -d <in >out 2>err || fail=3D1 + GZIP=3D$opt gzip <exp >inopt 2>err || fail=3D1 + compare in inopt || fail=3D1 + GZIP=3D$opt gzip -d <in >out 2>err || fail=3D1 compare exp out || fail=3D1 done =20 diff --git a/util.c b/util.c index e3eb739..c799ac1 100644 --- a/util.c +++ b/util.c @@ -291,66 +291,6 @@ make_simple_name (char *name) } #endif =20 -/* Convert the value of the environment variable ENVVAR_NAME - to a newly allocated argument vector, and set *ARGCP and *ARGVP - to the number of arguments and to the vector, respectively. - Make the new vector's zeroth element equal to the old **ARGVP. - Return a pointer to the newly allocated string storage. - - If the vector would be empty, do not allocate storage, - do not set *ARGCP and *ARGVP, and return NULL. */ - -#define SEPARATOR " \t" /* separators in env variable */ - -char *add_envopt( - int *argcp, /* pointer to argc */ - char ***argvp, /* pointer to argv */ - char const *envvar_name) /* name of environment variable */ -{ - char *p; /* running pointer through env variable */ - char **oargv; /* runs through old argv array */ - char **nargv; /* runs through new argv array */ - int nargc =3D 0; /* number of arguments in env variable */ - char *env_val; - - env_val =3D getenv(envvar_name); - if (env_val =3D=3D NULL) return NULL; - - env_val =3D xstrdup (env_val); - - for (p =3D env_val; *p; nargc++ ) { /* move through env_val *= / - p +=3D strspn(p, SEPARATOR); /* skip leading separators */ - if (*p =3D=3D '\0') break; - - p +=3D strcspn(p, SEPARATOR); /* find end of word */ - if (*p) *p++ =3D '\0'; /* mark it */ - } - if (nargc =3D=3D 0) { - free(env_val); - return NULL; - } - *argcp =3D nargc + 1; - /* Allocate the new argv array, with an extra element just in case - * the original arg list did not end with a NULL. - */ - nargv =3D xcalloc (*argcp + 1, sizeof (char *)); - oargv =3D *argvp; - *argvp =3D nargv; - - /* Copy the program name first */ - *nargv++ =3D *oargv; - - /* Then copy the environment args */ - for (p =3D env_val; nargc > 0; nargc--) { - p +=3D strspn(p, SEPARATOR); /* skip separators */ - *(nargv++) =3D p; /* store start */ - while (*p++) ; /* skip over word */ - } - - *nargv =3D NULL; - return env_val; -} - /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * Error handlers. */ diff --git a/znew.in b/znew.in index b09d967..e9d87f3 100644 --- a/znew.in +++ b/znew.in @@ -55,7 +55,7 @@ new=3D0 block=3D1024 # block is the disk block size (best guess, need not be exact) =20 -# Beware -s or --suffix in $GZIP. +# Beware -s or --suffix in $GZIP, used by gzip 1.13 and earlier. unset GZIP ext=3D.gz =20 --=20 2.45.2
Paul Eggert <eggert@HIDDEN>
:bug-gzip@HIDDEN
.
Full text available.bug-gzip@HIDDEN
:bug#76197
; Package gzip
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.