diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/grep.c | 7 |
2 files changed, 8 insertions, 1 deletions
@@ -14,6 +14,8 @@ GNU grep NEWS -*- outline -*- 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. + Also, grep now treates GREP_COLOR like GREP_COLORS by silently + ignoring it if it attempts to inject ANSI terminal escapes. Regular expressions with stray backslashes now cause warnings, as their unspecified behavior can lead to unexpected results. @@ -2911,7 +2911,12 @@ main (int argc, char **argv) /* Legacy. */ char *userval = getenv ("GREP_COLOR"); if (userval != NULL && *userval != '\0') - selected_match_color = context_match_color = userval; + for (char *q = userval; *q == ';' || c_isdigit (*q); q++) + if (!q[1]) + { + selected_match_color = context_match_color = userval; + break; + } /* New GREP_COLORS has priority. */ parse_grep_colors (); |