grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v3.5-15-g790be1f


From: Paul Eggert
Subject: grep branch, master, updated. v3.5-15-g790be1f
Date: Tue, 3 Nov 2020 14:10:05 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  790be1fb2a5949277ccc89f8a1c9c49733045d85 (commit)
      from  ffc6e407e3657598702ba24ab1ba3a6b8ab253ea (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=790be1fb2a5949277ccc89f8a1c9c49733045d85


commit 790be1fb2a5949277ccc89f8a1c9c49733045d85
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Tue Nov 3 11:09:47 2020 -0800

    grep: remove GREP_OPTIONS
    
    * NEWS: Mention this.
    * doc/grep.in.1:
    Remove GREP_OPTIONS documentation.
    * doc/grep.texi (Environment Variables):
    Move GREP_OPTIONS stuff into a “no longer implemented” paragraph.
    * src/grep.c (prepend_args, prepend_default_options): Remove.
    (main): Do not look at GREP_OPTIONS.
    * tests/Makefile.am (TESTS_ENVIRONMENTS):
    * tests/init.cfg (vars_): Remove GREP_OPTIONS.

diff --git a/NEWS b/NEWS
index 34a2057..055a450 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ GNU grep NEWS                                    -*- outline 
-*-
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Changes in behavior
+
+  The GREP_OPTIONS environment variable no longer affects grep's behavior.
+  The variable was declared obsolescent in grep 2.21 (2014), and since
+  then any use had caused grep to issue a diagnostic.
+
 ** Bug fixes
 
   grep's DFA matcher performed an invalid regex transformation
diff --git a/doc/grep.in.1 b/doc/grep.in.1
index 7d5dfe5..c56c404 100644
--- a/doc/grep.in.1
+++ b/doc/grep.in.1
@@ -1001,17 +1001,6 @@ The shell command
 .B "locale \-a"
 lists locales that are currently available.
 .TP
-.B GREP_OPTIONS
-This variable specifies default options
-to be placed in front of any explicit options.
-As this causes problems when writing portable scripts,
-this feature will be removed in a future release of
-.BR grep ,
-and
-.B grep
-warns if it is used.
-Please use an alias or script instead.
-.TP
 .B GREP_COLOR
 This variable specifies the color used to highlight matched (non-empty) text.
 It is deprecated in favor of
diff --git a/doc/grep.texi b/doc/grep.texi
index 0c0bb12..fce36cd 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -887,24 +887,6 @@ the @code{terminfo} library.
 
 @table @env
 
-@item GREP_OPTIONS
-@vindex GREP_OPTIONS @r{environment variable}
-@cindex default options environment variable
-This variable specifies default options to be placed in front of any
-explicit options.
-As this causes problems when writing portable scripts, this feature
-will be removed in a future release of @command{grep}, and @command{grep}
-warns if it is used.  Please use an alias or script instead.
-For example, if @command{grep} is in the directory @samp{/usr/bin} you
-can prepend @file{$HOME/bin} to your @env{PATH} and create an
-executable script @file{$HOME/bin/grep} containing the following:
-
-@example
-#! /bin/sh
-export PATH=/usr/bin
-exec grep --color=auto --devices=skip "$@@"
-@end example
-
 @item GREP_COLOR
 @vindex GREP_COLOR @r{environment variable}
 @cindex highlight markers
@@ -1097,6 +1079,20 @@ and only when @env{POSIXLY_CORRECT} is not set.
 
 @end table
 
+The @env{GREP_OPTIONS} environment variable of @command{grep} 2.20 and
+earlier is no longer supported, as it caused problems when writing
+portable scripts.  To make arbitrary changes to how @command{grep}
+works, you can use an alias or script instead.  For example, if
+@command{grep} is in the directory @samp{/usr/bin} you can prepend
+@file{$HOME/bin} to your @env{PATH} and create an executable script
+@file{$HOME/bin/grep} containing the following:
+
+@example
+#! /bin/sh
+export PATH=/usr/bin
+exec grep --color=auto --devices=skip "$@@"
+@end example
+
 
 @node Exit Status
 @section Exit Status
diff --git a/src/grep.c b/src/grep.c
index bd6ca53..cc2b962 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2106,66 +2106,6 @@ setmatcher (char const *m, int matcher)
   die (EXIT_TROUBLE, 0, _("invalid matcher %s"), m);
 }
 
-/* Find the white-space-separated options specified by OPTIONS, and
-   using BUF to store copies of these options, set ARGV[0], ARGV[1],
-   etc. to the option copies.  Return the number N of options found.
-   Do not set ARGV[N] to NULL.  If ARGV is NULL, do not store ARGV[0]
-   etc.  Backslash can be used to escape whitespace (and backslashes).  */
-static size_t
-prepend_args (char const *options, char *buf, char **argv)
-{
-  char const *o = options;
-  char *b = buf;
-  size_t n = 0;
-
-  for (;;)
-    {
-      while (c_isspace (to_uchar (*o)))
-        o++;
-      if (!*o)
-        return n;
-      if (argv)
-        argv[n] = b;
-      n++;
-
-      do
-        if ((*b++ = *o++) == '\\' && *o)
-          b[-1] = *o++;
-      while (*o && ! c_isspace (to_uchar (*o)));
-
-      *b++ = '\0';
-    }
-}
-
-/* Prepend the whitespace-separated options in OPTIONS to the argument
-   vector of a main program with argument count *PARGC and argument
-   vector *PARGV.  Return the number of options prepended.  */
-static int
-prepend_default_options (char const *options, int *pargc, char ***pargv)
-{
-  if (options && *options)
-    {
-      char *buf = xmalloc (strlen (options) + 1);
-      size_t prepended = prepend_args (options, buf, NULL);
-      int argc = *pargc;
-      char *const *argv = *pargv;
-      char **pp;
-      enum { MAX_ARGS = MIN (INT_MAX, SIZE_MAX / sizeof *pp - 1) };
-      if (MAX_ARGS - argc < prepended)
-        xalloc_die ();
-      pp = xmalloc ((prepended + argc + 1) * sizeof *pp);
-      *pargc = prepended + argc;
-      *pargv = pp;
-      *pp++ = *argv++;
-      pp += prepend_args (options, buf, pp);
-      while ((*pp++ = *argv++))
-        continue;
-      return prepended;
-    }
-
-  return 0;
-}
-
 /* Get the next non-digit option from ARGC and ARGV.
    Return -1 if there are no more options.
    Process any digit options that were encountered on the way,
@@ -2530,7 +2470,7 @@ main (int argc, char **argv)
   char *keys = NULL;
   size_t keycc = 0, keyalloc = 0;
   int matcher = -1;
-  int opt, prepended;
+  int opt;
   int prev_optind, last_recursive;
   int fread_errno;
   intmax_t default_context;
@@ -2574,11 +2514,6 @@ main (int argc, char **argv)
   if (!pattern_table)
     xalloc_die ();
 
-  prepended = prepend_default_options (getenv ("GREP_OPTIONS"), &argc, &argv);
-  if (prepended)
-    error (0, 0, _("warning: GREP_OPTIONS is deprecated;"
-                   " please use an alias or script"));
-
   while (prev_optind = optind,
          (opt = get_nondigit_option (argc, argv, &default_context)) != -1)
     switch (opt)
@@ -3056,7 +2991,7 @@ main (int argc, char **argv)
     {
       files = argv + optind;
     }
-  else if (directories == RECURSE_DIRECTORIES && prepended < last_recursive)
+  else if (directories == RECURSE_DIRECTORIES && 0 < last_recursive)
     {
       static char *const cwd_only[] = { (char *) ".", NULL };
       files = cwd_only;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cc55c7e..480bfb4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -237,7 +237,6 @@ TESTS_ENVIRONMENT =                         \
   LOCALE_FR='$(LOCALE_FR)'                     \
   LOCALE_FR_UTF8='$(LOCALE_FR_UTF8)'           \
   AWK=$(AWK)                                   \
-  GREP_OPTIONS=''                              \
   LC_ALL=C                                     \
   abs_top_builddir='$(abs_top_builddir)'       \
   abs_top_srcdir='$(abs_top_srcdir)'           \
diff --git a/tests/init.cfg b/tests/init.cfg
index 0bd5aa2..4abe55a 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -21,7 +21,6 @@ fi
 vars_='
 GREP_COLOR
 GREP_COLORS
-GREP_OPTIONS
 TERM
 '
 envvar_check_fail=0

-----------------------------------------------------------------------

Summary of changes:
 NEWS              |  6 +++++
 doc/grep.in.1     | 11 ---------
 doc/grep.texi     | 32 +++++++++++---------------
 src/grep.c        | 69 ++-----------------------------------------------------
 tests/Makefile.am |  1 -
 tests/init.cfg    |  1 -
 6 files changed, 22 insertions(+), 98 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]