Date: Wed, 27 Sep 2023 22:30:43 -0500 From: Kyle Evans <kevans@FreeBSD.org> To: Jamie Landeg-Jones <jamie@catflap.org>, freebsd-current@freebsd.org Subject: Re: grep(1) bug - duplicate output lines Message-ID: <8d0658e9-8984-a241-ad1d-e5aa1328d7fa@FreeBSD.org> In-Reply-To: <202309280240.38S2esgN015958@donotpassgo.dyslexicfish.net> References: <202309280240.38S2esgN015958@donotpassgo.dyslexicfish.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On 9/27/23 21:40, Jamie Landeg-Jones wrote: > When using color=always and a regex of '.' (for example), output lines > are duplicated. > > $ grep --version > grep (BSD grep, GNU compatible) 2.6.0-FreeBSD > > E.G.: > > $ grep --color=always . /etc/fstab > > Cheers, Jamie > I think this is what we want: https://people.freebsd.org/~kevans/grep-color.diff Basically, for --color with . we actually get each individual character reported, and we can't really coalesce that. (Well, we could, but I'll leave that for future improvement). Once you hit 32 matches in the same line, we dump out the first set of matches then check again for any more that just didn't fit the first time. Unfortunately, that logic wasn't prepared to avoid terminating the first time in case we have more matches to output, so we'd terminate, then refill our matches with the remainder of the line and output the leading context again + terminate again. Thanks, Kyle Evans
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8d0658e9-8984-a241-ad1d-e5aa1328d7fa>