Subject: Re: bug#75796: Very inefficient use of --color escape sequences

From: Peter White <[email-masked]>
Date: Fri, 24 Jan 2025 04:39:23 +0000

On Fri, Jan 24, 2025 at 03:20:28AM +0000, Peter White wrote:
> Hi there,
> 
> I just stumbled on this by accidentally redirecting the output of a
> colored grep invocation to a file like so:
> 	
> 	$ grep --color=always . /sys/kernel/mm/transparent_hugepage/* >thp-status.txt 2>/dev/null
> 	# for convenience the 1st line of actual uncolored output
> 	/sys/kernel/mm/transparent_hugepage/defrag:always defer defer+madvise [madvise] never
> 	
> Subsequently opening said file in vim I was overwhelmed with escape
> sequences. From the looks of it every character in the match gets its
> very own color escape sequence as opposed to the string indicating the
> path to the file (everything before ':')

I did have a look at the code, after all, and even tried a premature
"fix" which broke the foad1 test in the debian source package. But that
made me realize that this is not a bug at all and grep did as designed
by highlighting every single match which just happened to be every
single character because of '.' being the pattern.

I am sorry for wasting anyone's time and can only hope that this
retraction reaches them before they might go chasing ghosts.

Peter White