git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] grep: prefer builtin over external one when coloring results

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Mar 16, 2009, 17:31 UTC
Message-ID
<49BE8CE5.2020603@lsrfire.ath.cx>
In-Reply-To
<1237170004-27768-1-git-send-email-pclouds@gmail.com>
pclouds@gmail.com schrieb:
Show 24 quoted lines
> As far as I know, not all grep programs support coloring, so we should
> rely on builtin grep. If you want external grep, set
> color.grep.external to empty string.
> 
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  How about this?
> 
>  builtin-grep.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/builtin-grep.c b/builtin-grep.c
> index 9e7e766..89489dd 100644
> --- a/builtin-grep.c
> +++ b/builtin-grep.c
> @@ -825,6 +825,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
>  		}
>  	}
>  
> +	if (opt.color && !opt.color_external)
> +		builtin_grep = 1;
>  	if (!opt.pattern_list)
>  		die("no pattern given.");
>  	if ((opt.regflags != REG_NEWLINE) && opt.fixed)
Makes sense, thanks!
René
Previous: pclouds@gmail.com
Message 10 of 10 in “grep: color search patterns”
  1. 0/5 grep: color search patternsRené Scharfe, Mar 7, 2009
  2. 1/5 grep: micro-optimize hit collection for AND nodesRené Scharfe, Mar 7, 2009
  3. 2/5 grep: remove grep_opt argument from match_expr_eval()René Scharfe, Mar 7, 2009
  4. 3/5 grep: add pmatch and eflags arguments to match_one_pattern()René Scharfe, Mar 7, 2009
  5. 4/5 grep: color patterns in outputRené Scharfe, Mar 7, 2009
  6. 5/5 grep: add support for coloring with external grepsRené Scharfe, Mar 7, 2009
  7. Nguyen Thai Ngoc DuyMar 10, 2009
  8. René ScharfeMar 10, 2009
  9. grep: prefer builtin over external one when coloring resultspclouds@gmail.com, Mar 16, 2009
  10. René ScharfeMar 16, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.