GNU bug report logs - #51255
#39678: grep --ignore-case --color does not always color the matches

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: grep; Reported by: Tomasz Dziendzielski <tomasz.dziendzielski@HIDDEN>; merged with #39678, #51256, #51257; dated Mon, 18 Oct 2021 04:00:02 UTC; Maintainer for grep is bug-grep@HIDDEN.
Merged 39678 51255 51256 51257. Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Merged 51255 51256 51257. Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Oct 2021 03:59:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 17 23:59:14 2021
Received: from localhost ([127.0.0.1]:45550 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mcJnt-0008Sj-PR
	for submit <at> debbugs.gnu.org; Sun, 17 Oct 2021 23:59:14 -0400
Received: from lists.gnu.org ([209.51.188.17]:47618)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tomasz.dziendzielski@HIDDEN>) id 1mcDqh-0007Ix-WA
 for submit <at> debbugs.gnu.org; Sun, 17 Oct 2021 17:37:44 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:47142)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <tomasz.dziendzielski@HIDDEN>)
 id 1mcDqh-0001Rm-NI
 for bug-grep@HIDDEN; Sun, 17 Oct 2021 17:37:43 -0400
Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]:37441)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <tomasz.dziendzielski@HIDDEN>)
 id 1mcDqg-0002HK-4o
 for bug-grep@HIDDEN; Sun, 17 Oct 2021 17:37:43 -0400
Received: by mail-ua1-x92a.google.com with SMTP id f4so2251061uad.4
 for <bug-grep@HIDDEN>; Sun, 17 Oct 2021 14:37:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:from:date:message-id:subject:to:cc;
 bh=zSjCPIx4dbKVOfXVussoCC6+Ci2sA5Gtrmo2/WUtamU=;
 b=GM3LnILOP19equKf/rMzvNtHIBZJHWcVN4SM4z1aqwVl//3GT7PK1TTD3T00y+OK77
 B+RjVZaptGnt4UdmiZO88aEeV9N8mtC5O5fJVUgb0QVqStNiNdjQzH9vROySqiiqEP/6
 WwHLIosFP31sV3bk96sE8Qln4chhdoaNoNDlvWHHTRSV5tVuFqHXxQZ5KFskUEDQFNS9
 czC594FDsxlKyYTPg8B4TGfUwlaxmLLRG8y3jia3Bcn1avsyskbRFfs91VlnjLKHcMn7
 Z7nQXGPYipeoMxYashs2vgcwvVSf9Vq6nvByekZOD6sxJh2B3NjEpLDYYjNRAFFrDbtn
 5UTw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc;
 bh=zSjCPIx4dbKVOfXVussoCC6+Ci2sA5Gtrmo2/WUtamU=;
 b=NqABWaWge5QGeUyCz4l/yhHmAlI2aUcDSbQ/L/7spa9GI5CQsdVcpo6bqiH8kNw2Oh
 S0ubFgpk2Ev7sfz1uDSNICXri1JJuFe4rlqPChC2DovFi2NsH3+yiGxnZQmCR5ZYeRbs
 CFpE7xXRenFjCLMseLy1oNGIEPsQmRQC2BEnUJLN7V4xEMnDR2dgrA6YxwjgA3drBPfk
 G1saBydiEh6pFsy17UUxXmRsPrlOPvqK4WvtpEpZsbPwUvjiHi2OaXY3d1GNOeUhxy2b
 BEnOUvtIjByTRqq0ZBY/RSCctzwmKAEd+3RbuyvCBgHM5b/kvnaMdwfg2qnlDzNciHST
 g/sA==
X-Gm-Message-State: AOAM5311rrxCoj7FiBLLMKOIOo6Mv/U59aDPZqeRNgRvoHYxk8KKHSR1
 bwIzVgdmbp/unvOICFuJ5M8WKqceuKwDGF1zcb8=
X-Google-Smtp-Source: ABdhPJzwCwJ7AQr8fRNdpolI/40otYnRqIpsCUjKhzRSRiRgBfWb3NzKgksupnuSYHk/4qNh4tJ3bFfuiiH9GatHILY=
X-Received: by 2002:ab0:35cc:: with SMTP id x12mr22800878uat.45.1634506660847; 
 Sun, 17 Oct 2021 14:37:40 -0700 (PDT)
MIME-Version: 1.0
From: Tomasz Dziendzielski <tomasz.dziendzielski@HIDDEN>
Date: Sun, 17 Oct 2021 23:37:30 +0200
Message-ID: <CAJkqNs3JauqDc7cy6YTJR2XunmzZzyG5ogi4UJEarVCGcXWsng@HIDDEN>
Subject: #39678: grep --ignore-case --color does not always color the matches
To: bensberg@HIDDEN, bug-grep@HIDDEN
Content-Type: multipart/mixed; boundary="000000000000e79a3705ce933c51"
Received-SPF: pass client-ip=2607:f8b0:4864:20::92a;
 envelope-from=tomasz.dziendzielski@HIDDEN; helo=mail-ua1-x92a.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sun, 17 Oct 2021 23:59:07 -0400
Cc: 39678 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--000000000000e79a3705ce933c51
Content-Type: multipart/alternative; boundary="000000000000e79a2705ce933c4f"

--000000000000e79a2705ce933c4f
Content-Type: text/plain; charset="UTF-8"

Hello,
I did some investigation and it seems the problem with "\a" is not that the
output is not colored but that it's printed at all while it should not be.
It's being printed even when re_search in EGexecute doesn't return a match.
As a result the for loop in print_line_middle is not being run - this means
the "a" output that you see is not from the matched string but from the
rest of the line. To fix this I suggest to return NULL from
print_line_middle if `b` variable equals NULL - which means the loop was
not executed.

I'm sending the patch with the fix in the attachment.

Best regards,
Tomasz Dziendzielski

--000000000000e79a2705ce933c4f
Content-Type: text/html; charset="UTF-8"

<div dir="ltr"><div>Hello,<br></div><div>I did some investigation and it seems the problem
 with &quot;\a&quot; is not that the output is not colored but that it&#39;s printed 
at all while it should not be. It&#39;s being printed even when re_search in
 EGexecute  doesn&#39;t return a match. As a result the for loop in 
print_line_middle is not being run - this means the &quot;a&quot; output that you 
see is not from the matched string but from the rest of the line. To fix
 this I suggest to return NULL from print_line_middle if `b` variable 
equals NULL - which means the loop was not executed.<br></div><div><br></div><div>I&#39;m sending the patch with the fix in the attachment.</div><div><br></div><div>Best regards,</div><div>Tomasz Dziendzielski</div></div>

--000000000000e79a2705ce933c4f--

--000000000000e79a3705ce933c51
Content-Type: text/x-patch; charset="US-ASCII"; 
	name="0001-grep-Don-t-print-line-if-matcher-returned-nothing.patch"
Content-Disposition: attachment; 
	filename="0001-grep-Don-t-print-line-if-matcher-returned-nothing.patch"
Content-Transfer-Encoding: base64
Content-ID: <f_kuvr09bg0>
X-Attachment-Id: f_kuvr09bg0

RnJvbSAwNzgwNTI1OWI5YmYzZTE2Nzg0N2ExY2Y1MzA4YjZjNTQwMThiNzA5IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBUb21hc3ogRHppZW5kemllbHNraSA8dG9tYXN6LmR6aWVuZHpp
ZWxza2lAZ21haWwuY29tPgpEYXRlOiBTdW4sIDE3IE9jdCAyMDIxIDIxOjQ3OjI4ICswMjAwClN1
YmplY3Q6IFtQQVRDSF0gZ3JlcDogRG9uJ3QgcHJpbnQgbGluZSBpZiBtYXRjaGVyIHJldHVybmVk
IG5vdGhpbmcKCkl0IGNhbiBoYXBwZW4gdGhhdCByZV9zZWFyY2ggaW4gRUdleGVjdXRlIGZhaWxz
IGFuZCByZXR1cm5zIG5vdGhpbmcgc28KZm9yIGxvb3AgaW4gcHJpbnRfbGluZV9taWRkbGUgcnVu
cyB6ZXJvIHRpbWVzIGJ1dCBzdGlsbCBzdGlsbCByZXR1cm5zCnRyYXNoIHVuZGVyIGBjdXJgIHZh
cmlhYmxlLCBzbyBncmVwIHRoaW5rcyBpdCBtYXRjaGVkIHNvbWV0aGluZyBhbmQgdGhlbgpyZXR1
cm5zIHdob2xlIGxpbmUuCgpGaXhlcyBidWcgMzk2NzguIElzc3VlIHdhcyB0aGF0IHNlY29uZCBv
ZiBiZWxvdyBjb21tYW5kcyBkaWQgbm90IGNvbG9yCnRoZSAiYSIgY2hhcmFjdGVyOgp8IGVjaG8g
YSB8IGdyZXAgLWkgLS1jb2xvciAnXEEnCnwgZWNobyBhIHwgZ3JlcCAtaSAtL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ICAgY3Vy
ID0gbWlkOworICBlbHNlIGlmIChiID09IE5VTEwpCisgICAgcmV0dXJuIE5VTEw7CiAKICAgcmV0
dXJuIGN1cjsKIH0KLS0gCjIuMzMuMAoK
--000000000000e79a3705ce933c51--




Acknowledgement sent to Tomasz Dziendzielski <tomasz.dziendzielski@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-grep@HIDDEN. Full text available.
Report forwarded to bug-grep@HIDDEN:
bug#51255; Package grep. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 24 Nov 2021 03:00:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.