summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--doc/grep.in.128
-rw-r--r--doc/grep.texi71
-rw-r--r--src/grep.c9
4 files changed, 43 insertions, 69 deletions
diff --git a/NEWS b/NEWS
index f6a1e8c3..33658fc7 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,10 @@ GNU grep NEWS -*- outline -*-
release 2.5.3 (2007), now warn that they are obsolescent and should
be replaced by grep -E and grep -F.
+ The confusing GREP_COLOR environment variable is now obsolescent.
+ Instead of GREP_COLOR='xxx', use GREP_COLORS='mt=xxx'. grep now
+ warns if GREP_COLOR is used and is not overridden by GREP_COLORS.
+
Regular expressions with stray backslashes now cause warnings, as
their unspecified behavior can lead to unexpected results.
For example, '\a' and 'a' are not always equivalent
diff --git a/doc/grep.in.1 b/doc/grep.in.1
index 17bf3eca..0423866c 100644
--- a/doc/grep.in.1
+++ b/doc/grep.in.1
@@ -295,9 +295,6 @@ groups of context lines) with escape sequences to display them in color
on the terminal.
The colors are defined by the environment variable
.BR GREP_COLORS .
-The deprecated environment variable
-.B GREP_COLOR
-is still supported, but its setting does not have priority.
.I WHEN
is
.BR never ", " always ", or " auto .
@@ -1009,31 +1006,6 @@ The shell command
.B "locale \-a"
lists locales that are currently available.
.TP
-.B GREP_COLOR
-This variable specifies the color used to highlight matched (non-empty) text.
-It is deprecated in favor of
-.BR GREP_COLORS ,
-but still supported.
-The
-.BR mt ,
-.BR ms ,
-and
-.B mc
-capabilities of
-.B GREP_COLORS
-have priority over it.
-It can only specify the color used to highlight
-the matching non-empty text in any matching line
-(a selected line when the
-.B \-v
-command-line option is omitted,
-or a context line when
-.B \-v
-is specified).
-The default is
-.BR 01;31 ,
-which means a bold red foreground text on the terminal's default background.
-.TP
.B GREP_COLORS
Specifies the colors and other attributes
used to highlight various parts of the output.
diff --git a/doc/grep.texi b/doc/grep.texi
index 69b52dc2..e2a8b2ee 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -308,10 +308,6 @@ The colors are defined by the environment variable @env{GREP_COLORS}
and default to @samp{ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36}
for bold red matched text, magenta file names, green line numbers,
green byte offsets, cyan separators, and default terminal colors otherwise.
-The deprecated environment variable @env{GREP_COLOR} is still supported,
-but its setting does not have priority;
-it defaults to @samp{01;31} (bold red)
-which only covers the color for matched text.
@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
@item -L
@@ -816,8 +812,10 @@ this option can be used with commands like
@node Environment Variables
@section Environment Variables
-The behavior of @command{grep} is affected
-by the following environment variables.
+The behavior of @command{grep} is affected by several environment
+variables, the most important of which control the locale, which
+specifies how @command{grep} interprets characters in its patterns and
+data.
@vindex LANGUAGE @r{environment variable}
@vindex LC_ALL @r{environment variable}
@@ -842,7 +840,34 @@ or if @command{grep} was not compiled
with national language support (NLS).
The shell command @code{locale -a} lists locales that are currently available.
-Many of the environment variables in the following list let you
+@cindex environment variables
+The following environment variables affect the behavior of @command{grep}.
+
+@table @env
+
+@item GREP_COLOR
+@vindex GREP_COLOR @r{environment variable}
+@cindex highlight markers
+This obsolescent variable interacts with @env{GREP_COLORS}
+confusingly, and @command{grep} warns if it is set and is not
+overridden by @env{GREP_COLORS}. Instead of
+@samp{GREP_COLOR='@var{color}'}, you can use
+@samp{GREP_COLORS='mt=@var{color}'}.
+
+@item GREP_COLORS
+@vindex GREP_COLORS @r{environment variable}
+@cindex highlight markers
+This variable specifies the colors and other attributes
+used to highlight various parts of the output.
+Its value is a colon-separated list of @code{terminfo} capabilities
+that defaults to @samp{ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36}
+with the @samp{rv} and @samp{ne} boolean capabilities omitted (i.e., false).
+The two-letter capability names
+refer to terminal ``capabilities,'' the ability
+of a terminal to highlight text, or change its color, and so on.
+These capabilities are stored in an online database and accessed by
+the @code{terminfo} library.
+Nonempty capability values
control highlighting using
Select Graphic Rendition (SGR)
commands interpreted by the terminal or terminal emulator.
@@ -870,38 +895,6 @@ for 88-color and 256-color modes foreground colors,
and @samp{48;5;0} to @samp{48;5;255}
for 88-color and 256-color modes background colors.
-The two-letter names used in the @env{GREP_COLORS} environment variable
-(and some of the others) refer to terminal ``capabilities,'' the ability
-of a terminal to highlight text, or change its color, and so on.
-These capabilities are stored in an online database and accessed by
-the @code{terminfo} library.
-
-@cindex environment variables
-
-@table @env
-
-@item GREP_COLOR
-@vindex GREP_COLOR @r{environment variable}
-@cindex highlight markers
-This variable specifies the color used to highlight matched (non-empty) text.
-It is deprecated in favor of @env{GREP_COLORS}, but still supported.
-The @samp{mt}, @samp{ms}, and @samp{mc} capabilities of @env{GREP_COLORS}
-have priority over it.
-It can only specify the color used to highlight
-the matching non-empty text in any matching line
-(a selected line when the @option{-v} command-line option is omitted,
-or a context line when @option{-v} is specified).
-The default is @samp{01;31},
-which means a bold red foreground text on the terminal's default background.
-
-@item GREP_COLORS
-@vindex GREP_COLORS @r{environment variable}
-@cindex highlight markers
-This variable specifies the colors and other attributes
-used to highlight various parts of the output.
-Its value is a colon-separated list of @code{terminfo} capabilities
-that defaults to @samp{ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36}
-with the @samp{rv} and @samp{ne} boolean capabilities omitted (i.e., false).
Supported capabilities are as follows.
@table @code
diff --git a/src/grep.c b/src/grep.c
index 4109ae46..edefac6c 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -295,8 +295,7 @@ static const char *group_separator = SEP_STR_GROUP;
This only leaves red, magenta, green, and cyan (and their bold
counterparts) and possibly bold blue. */
/* The color strings used for matched text.
- The user can overwrite them using the deprecated
- environment variable GREP_COLOR or the new GREP_COLORS. */
+ The user can overwrite them using the GREP_COLORS environment variable. */
static const char *selected_match_color = "01;31"; /* bold red */
static const char *context_match_color = "01;31"; /* bold red */
@@ -2916,6 +2915,12 @@ main (int argc, char **argv)
/* New GREP_COLORS has priority. */
parse_grep_colors ();
+
+ /* Warn if GREP_COLOR has an effect, since it's deprecated. */
+ if (selected_match_color == userval || context_match_color == userval)
+ error (0, 0, _("warning: GREP_COLOR='%s' is deprecated;"
+ " use GREP_COLORS='mt=%s'"),
+ userval, userval);
}
initialize_unibyte_mask ();