GNU bug report logs - #51256
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, #51255, #51257; dated Mon, 18 Oct 2021 04:00:03 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:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 17 23:59:38 2021
Received: from localhost ([127.0.0.1]:45554 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mcJoB-0008TG-9v
	for submit <at> debbugs.gnu.org; Sun, 17 Oct 2021 23:59:38 -0400
Received: from lists.gnu.org ([209.51.188.17]:50624)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tomasz.dziendzielski@HIDDEN>) id 1mcEF0-00080K-ID
 for submit <at> debbugs.gnu.org; Sun, 17 Oct 2021 18:02:50 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:51062)
 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 1mcEEz-0004eE-VM
 for bug-grep@HIDDEN; Sun, 17 Oct 2021 18:02:50 -0400
Received: from mail-ua1-x936.google.com ([2607:f8b0:4864:20::936]:41922)
 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 1mcEEy-0003Iq-Ae
 for bug-grep@HIDDEN; Sun, 17 Oct 2021 18:02:49 -0400
Received: by mail-ua1-x936.google.com with SMTP id r17so4208291uaf.8
 for <bug-grep@HIDDEN>; Sun, 17 Oct 2021 15:02:47 -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=6UDvdp5bpFIf78JAvStQfQJma/jdf8AZ/asrwDWi0vc=;
 b=NHoycZCHc66JY9wox7qMfcDxIYau392YnX98PQwUyjbRo8Olr3Nr6DWFnYbggk751o
 8pIYgwiXwYnwdHdlXDbw1FhIWVhQ8j6E4oJz7kvIbMw8K9+Bhxcxm7WRdVrpUMgSS+Ul
 QyX1fECbGVp7nX+8mX7tOXmFVppvzbfqnRsxkVTpK7wEpXQ7zXfjVQEd6CLszdlMUssY
 VRTMzx3XahGVlWGrQ2x+9MfLex/hvM8ykO1whpq8BjrE18xqRAJUL5D+goQzJazKuCS+
 UBClrAjCnrkB8nu4cDtYYakDuNK2tGuSpZ3chauE7F4M5bizVaKW47dR/QgrUFocge8g
 g6Sg==
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=6UDvdp5bpFIf78JAvStQfQJma/jdf8AZ/asrwDWi0vc=;
 b=u0XQRHLGtxOqEcJVEnFKIVEpMV6YK4g0QQt77sD5RAZRAZ4/ufR6dopGXj1n7vAU/m
 0HsPydTW5LIEfRe6A6cWiBhUUuNbMaJs5lnjCXv694P+B2LsNQWnuZDrCRwwdAqnXiiY
 JjdYfcUvDTZZUgtJ0o+uTSWByn/UWrSnniSyryqPXcyB4thxB3wGc977m2yRNJhXxbZG
 IBpZwbEgTdIgyv06dqaXEsoNcbuplxz9KPNkq1QLe2MQpiMVuernAPxU30Of5w4FGXkw
 ukRuFXvXEXYwT/32Q9UiNdZ0ax9KOSWLiu99JK0QZugPlg5vCD+mfugZoO/SB99ATs65
 xG2A==
X-Gm-Message-State: AOAM5322OA4SH5JO6pvOkL02sJIMm2Vloze+wtCY/94tRsULLKJE0jl2
 VHL2hPlMDFqPyR+5GzRmop8mXVDkDMSnt8ZAQit2nFgJ
X-Google-Smtp-Source: ABdhPJwT0OW+SlfQzMYcDzJx723oF+Xu1xkYa0M35mwVmYCoFYCxbdOOMxwdpyZNzysvAuiKrixRPISuI+Lo/snpvZY=
X-Received: by 2002:a67:d606:: with SMTP id n6mr24240710vsj.51.1634508167065; 
 Sun, 17 Oct 2021 15:02:47 -0700 (PDT)
MIME-Version: 1.0
From: Tomasz Dziendzielski <tomasz.dziendzielski@HIDDEN>
Date: Mon, 18 Oct 2021 00:02:36 +0200
Message-ID: <CAJkqNs1AV05yqKSbch7rL8YX+=bjbfeUMWOyLN7V87K2U-2oTA@HIDDEN>
Subject: grep --ignore-case --color does not always color the matches
To: bug-grep@HIDDEN
Content-Type: multipart/mixed; boundary="000000000000aecb8205ce93967e"
Received-SPF: pass client-ip=2607:f8b0:4864:20::936;
 envelope-from=tomasz.dziendzielski@HIDDEN; helo=mail-ua1-x936.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: -3.3 (---)

--000000000000aecb8205ce93967e
Content-Type: multipart/alternative; boundary="000000000000aecb7f05ce93967c"

--000000000000aecb7f05ce93967c
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

--000000000000aecb7f05ce93967c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div class=3D"gmail_quote" dir=3D"auto"><div dir=3D"ltr" =
class=3D"gmail_attr">Hello,</div><div dir=3D"ltr" class=3D"gmail_attr">I di=
d 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=20
at all while it should not be. It&#39;s being printed even when re_search i=
n
 EGexecute  doesn&#39;t return a match. As a result the for loop in=20
print_line_middle is not being run - this means the &quot;a&quot; output th=
at you=20
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=20
equals NULL - which means the loop was not executed.</div><div dir=3D"ltr" =
class=3D"gmail_attr"><br></div><div dir=3D"ltr" class=3D"gmail_attr">I&#39;=
m sending the patch with the fix in the attachment.</div><div dir=3D"ltr" c=
lass=3D"gmail_attr"><br></div><div dir=3D"ltr" class=3D"gmail_attr">Best re=
gards,</div><div dir=3D"ltr" class=3D"gmail_attr">Tomasz Dziendzielski</div=
></div></div>

--000000000000aecb7f05ce93967c--

--000000000000aecb8205ce93967e
Content-Type: application/octet-stream; 
	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: <17c9046ad63139915c91>
X-Attachment-Id: 17c9046ad63139915c91

RnJvbSAwNzgwNTI1OWI5YmYzZTE2Nzg0N2ExY2Y1MzA4YjZjNTQwMThiNzA5IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBUb21hc3ogRHppZW5kemllbHNraSA8dG9tYXN6LmR6aWVuZHpp
ZWxza2lAZ21haWwuY29tPgpEYXRlOiBTdW4sIDE3IE9jdCAyMDIxIDIxOjQ3OjI4ICswMjAwClN1
YmplY3Q6IFtQQVRDSF0gZ3JlcDogRG9uJ3QgcHJpbnQgbGluZSBpZiBtYXRjaGVyIHJldHVybmVk
IG5vdGhpbmcKCkl0IGNhbiBoYXBwZW4gdGhhdCByZV9zZWFyY2ggaW4gRUdleGVjdXRlIGZhaWxz
IGFuZCByZXR1cm5zIG5vdGhpbmcgc28KZm9yIGxvb3AgaW4gcHJpbnRfbGluZV9taWRkbGUgcnVu
cyB6ZXJvIHRpbWVzIGJ1dCBzdGlsbCBzdGlsbCByZXR1cm5zCnRyYXNoIHVuZGVyIGBjdXJgIHZh
cmlhYmxlLCBzbyBncmVwIHRoaW5rcyBpdCBtYXRjaGVkIHNvbWV0aGluZyBhbmQgdGhlbgpyZXR1
cm5zIHdob2xlIGxpbmUuCgp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aGFyICpiID0gTlVMTDsKIAogICBmb3IgKGN1ciA9IGJlZzsKICAgICAgICAo
Y3VyIDwgbGltCkBAIC0xMjY5LDYgKzEyNjksOCBAQCBwcmludF9saW5lX21pZGRsZSAoY2hhciAq
YmVnLCBjaGFyICpsaW0sCiAgICAgY3VyID0gbGltOwogICBlbHNlIGlmIChtaWQpCiAgICAgY3Vy
ID0gbWlkOworICBlbHNlIGlmIChiID09IE5VTEwpCisgICAgcmV0dXJuIE5VTEw7CiAKICAgcmV0
dXJuIGN1cjsKIH0KLS0gCjIuMzMuMAoK
--000000000000aecb8205ce93967e--




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#51256; 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.