From nobody Thu Sep 28 03:30:43 2023 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RwzX53Z9Mz4vRKF for ; Thu, 28 Sep 2023 03:30:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RwzX52s2Rz3V6b; Thu, 28 Sep 2023 03:30:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695871845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UfHe/bUR9hj9Z+AAFSTeCPnF4ESXPV4EhhT7Xc1Wb0E=; b=GKbGMOVjrJJxQeu5R0MpNwzeX8heJLCVjWYND/xYdQKfsgB2kqt1AH8HbqoWplqBsEDSh/ zixBOG8t/4BeDygFVHh0CtqBStdEvT8uyljkHCcn/rybe0f8llCHgp2rpMrl23u2buOQvn FAOYWbDZT3cImsw3tLmRglj8oO5+BLAVjgJhPJKmOOZa+olgggEiSLC3Bjg1qW2aa1TwhC NVuIxDLCs3Waf74ZYcbZx3RrzBPUX+t8r+5IVfEIP0ur4jKMo51X0Kvj/v5Qi7w245tWJA hv57sC/PI8bxCMs6+h2UuEz6xyZ1smuzdsGk7I/7NBNsWXV2+/eSkHiJd2IQxQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695871845; a=rsa-sha256; cv=none; b=H57MZ8PLk2QwiXQhdFSw3U0Ko5LS5s98UThQ4QPzEEQJDrTHbSHZCdKgbDAOKY+L0OZ3ep JMZbnHkQ+utCf+rXlPVnrw5SVQ4HdvjvTZ7K1IVS9UnYisDgiYx06NASproHyxV9g1HJpx EhKxh+1hBGCSabi511X71gHYLLEPDxcbU2QkF7/jI1MfMVRa3p8xFNLNxt8tQTryZJH7mT wDtfJuMJEKkjnRZGFrNh/zoe0npyXfT4D926oywIphZWZXYUstGXzFpLRuEQJ6poYMZ9tN FZoRh8RC37OAPRDyGCDRE/sHptiSrJbkCYEhTOZuD4DyOVtnJkdrS4cP5t1yGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695871845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UfHe/bUR9hj9Z+AAFSTeCPnF4ESXPV4EhhT7Xc1Wb0E=; b=qe9xorlzbQVeHTEtWzeM/3f03PFUi5p0roNA1nvJMk01Mq3t7mUJAxt5S5AHSqEWIrh1bQ 6Gd4/pUc2yCJ89VlRSgjXA+BmXaxPNvUbh3S6JG55ALVQDES8CA55pWCBX9YJYchnZYsnp PRz3V/pzLH77NW38fFV2BLB7Pw04ildFF7GoP/7YIKvZVjOx9neafEyAoHWkjvIYOVD0+5 emsvJn/kdxJa4PAFZi/0xDxeYUIuveZrEljod3kVJZZwGtOpNzeZswhLgdqs1mj4sytGgV FvHal++UHuT5CkawRnu1PD5rEM8z+SbRjYdllQ4kVu6ayqzX+1Ndiqrps20RTw== Received: from [10.9.4.95] (unknown [209.182.120.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: kevans/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RwzX50CMRz1Qtt; Thu, 28 Sep 2023 03:30:44 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Message-ID: <8d0658e9-8984-a241-ad1d-e5aa1328d7fa@FreeBSD.org> Date: Wed, 27 Sep 2023 22:30:43 -0500 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: grep(1) bug - duplicate output lines Content-Language: en-US To: Jamie Landeg-Jones , freebsd-current@freebsd.org References: <202309280240.38S2esgN015958@donotpassgo.dyslexicfish.net> From: Kyle Evans In-Reply-To: <202309280240.38S2esgN015958@donotpassgo.dyslexicfish.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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