From 4ac5fa8959c6366f64815de3dd94e1327242af4a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 29 May 2022 16:41:50 -0700 Subject: grep: deprecate GREP_COLOR This is to avoid confusion such as that reported by Cholden in: https://bugs.gnu.org/55641 * src/grep.c (main): Warn if GREP_COLOR has an effect. --- src/grep.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') 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 (); -- cgit v1.2.1