From unknown Fri Jun 20 18:21:01 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#20088 <20088@debbugs.gnu.org> To: bug#20088 <20088@debbugs.gnu.org> Subject: Status: -a changes whether a match is found Reply-To: bug#20088 <20088@debbugs.gnu.org> Date: Sat, 21 Jun 2025 01:21:01 +0000 retitle 20088 -a changes whether a match is found reassign 20088 grep submitter 20088 Jim Meyering severity 20088 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 11 13:39:00 2015 Received: (at submit) by debbugs.gnu.org; 11 Mar 2015 17:39:00 +0000 Received: from localhost ([127.0.0.1]:43070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVkax-00059l-VI for submit@debbugs.gnu.org; Wed, 11 Mar 2015 13:39:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34873) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVkav-00059T-IP for submit@debbugs.gnu.org; Wed, 11 Mar 2015 13:38:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVkap-0003Mr-HG for submit@debbugs.gnu.org; Wed, 11 Mar 2015 13:38:52 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33872) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVkap-0003Mn-EA for submit@debbugs.gnu.org; Wed, 11 Mar 2015 13:38:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVkao-0006aG-H0 for bug-grep@gnu.org; Wed, 11 Mar 2015 13:38:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVkan-0003MS-HD for bug-grep@gnu.org; Wed, 11 Mar 2015 13:38:50 -0400 Received: from mail-ie0-x22d.google.com ([2607:f8b0:4001:c03::22d]:33591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVkan-0003MI-CO for bug-grep@gnu.org; Wed, 11 Mar 2015 13:38:49 -0400 Received: by iecvj10 with SMTP id vj10so236388iec.0 for ; Wed, 11 Mar 2015 10:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:cc:content-type; bh=CnAjzcXSrEx3qwpzeWtxuIGF3Kw8bO6+ui0IsHRXZo4=; b=gZu/hmf17ketNhh3kWokIDXB8uWVx3/pBU/AaljF5pa6go4qhUhDYX5egfEd18T6PJ k1t5o74GqSxYMoAPON3GbFuA2ZSbg69kOsZ9LKKAZ5PrRG/uzNhqS0nh+vaXYD1z9qDW YsLN0TwrMx6PhZgqbeAtgQub5MPI0sn5fWE3DH65HYi7xieAYh/Z0mLGstG2J1ZfcQUN +n/qAmBQYWXkRRYeWFRWea8TLFZ3kaLckrQ851mE12n5XjjL0NhqZqtJSomLXMbLZc7W cYnryGJgdcSLX9LC96qBjiNgNyMVqaRUVf3LnKx/H9t9ztEOIqGql65uVmSr5Z1EP2Df EwvA== X-Received: by 10.50.111.10 with SMTP id ie10mr92469345igb.15.1426095528383; Wed, 11 Mar 2015 10:38:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.171.101 with HTTP; Wed, 11 Mar 2015 10:38:28 -0700 (PDT) From: Jim Meyering Date: Wed, 11 Mar 2015 10:38:28 -0700 X-Google-Sender-Auth: FwKKtJ44WkFig4sgUKn9AtMslFI Message-ID: Subject: -a changes whether a match is found To: bug-grep@gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: Andreas Schwab X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --text (-a) is documented to change only the output, not grep's exit status. Yet, it does change the exit status here: $ printf "a\0b\n" | LC_ALL=C src/grep -la a.b; echo $? (standard input) 0 $ printf "a\0b\n" | LC_ALL=C src/grep -l a.b; echo $? 1 Noted by Andreas Schwab in https://bugs.gnu.org/20080. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 11 14:02:57 2015 Received: (at 20088) by debbugs.gnu.org; 11 Mar 2015 18:02:57 +0000 Received: from localhost ([127.0.0.1]:43100 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVky8-0007Cp-OC for submit@debbugs.gnu.org; Wed, 11 Mar 2015 14:02:57 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:60239) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVky5-0007CW-Q1 for 20088@debbugs.gnu.org; Wed, 11 Mar 2015 14:02:54 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 995F8A60039; Wed, 11 Mar 2015 11:02:47 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mPjDpBmstau4; Wed, 11 Mar 2015 11:02:45 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id B1B92A60038; Wed, 11 Mar 2015 11:02:45 -0700 (PDT) Message-ID: <55008342.7070203@cs.ucla.edu> Date: Wed, 11 Mar 2015 11:02:42 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Jim Meyering , 20088@debbugs.gnu.org Subject: Re: bug#20088: -a changes whether a match is found References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------030806090607040608020805" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 20088 Cc: Andreas Schwab X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------030806090607040608020805 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 03/11/2015 10:38 AM, Jim Meyering wrote: > --text (-a) is documented to change only the output, not grep's exit status. > It is documented, albeit too tersely. I tried to improve it by installing the attached. --------------030806090607040608020805 Content-Type: text/x-patch; name="0001-doc-clarify-how-a-matches.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-doc-clarify-how-a-matches.patch" >From c71daa9998680001ae52b6a3f3e7889b2d1eb512 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 11 Mar 2015 10:59:27 -0700 Subject: [PATCH] doc: clarify how -a matches * doc/grep.in.1, doc/grep.texi (File and Directory Selection): Give an example of how non-text bytes affect pattern matching in binary files. Fixes: bug#20080 --- doc/grep.in.1 | 6 ++++++ doc/grep.texi | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/grep.in.1 b/doc/grep.in.1 index dfd8288..2b513a8 100644 --- a/doc/grep.in.1 +++ b/doc/grep.in.1 @@ -383,6 +383,12 @@ is processes a binary file as if it were text; this is equivalent to the .B \-a option. +When processing binary data, +.B grep +may treat non-text bytes as line terminators; for example, the pattern +.RB ' . '\& +(period) might not match a null byte, as the null byte might be +treated as a line terminator. .I Warning: .B "grep \-\^\-binary\-files=text" might output binary garbage, diff --git a/doc/grep.texi b/doc/grep.texi index 7738677..18a1102 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -605,8 +605,10 @@ By default, @var{type} is @samp{binary}, and @command{grep} normally outputs either a one-line message saying that a binary file matches, or no message if there is no match. -When matching binary data, @command{grep} may treat non-text -bytes as line terminators. +When processing binary data, @command{grep} may treat non-text bytes +as line terminators; for example, the pattern @samp{.} (period) might +not match a null byte, as the null byte might be treated as a line +terminator even without the @option{-z} (@option{--null-data}) option. If @var{type} is @samp{without-match}, @command{grep} assumes that a binary file does not match; -- 2.1.0 --------------030806090607040608020805-- From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 11 17:53:58 2015 Received: (at 20088-done) by debbugs.gnu.org; 11 Mar 2015 21:53:58 +0000 Received: from localhost ([127.0.0.1]:43192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVoZi-0006ld-6c for submit@debbugs.gnu.org; Wed, 11 Mar 2015 17:53:58 -0400 Received: from mail-ie0-f179.google.com ([209.85.223.179]:35104) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVoZg-0006lI-9B for 20088-done@debbugs.gnu.org; Wed, 11 Mar 2015 17:53:56 -0400 Received: by ieclw3 with SMTP id lw3so1315753iec.2 for <20088-done@debbugs.gnu.org>; Wed, 11 Mar 2015 14:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=sW4PixprnkTgg6OoN8fz9ztdaFlXATRUFt+Y1QKSMUg=; b=KIzTvq8lEdO5BacsjXmHrhemHraXZOy4HRVXQ2iG+mF63BbZgoEq4IfP0+fKr7jEDj TkmsnBhngSKs2xVrl8tmfvufZvcVT0wKQ/nwW4srwzEXELVfalxQ8eULtBHuxMVzYU0W JLlB3T4JMz9hTR/aKLym7dCW/iube6fy1nH3RNGAm9qEL8Uj7CaVdq8OcdVnH9Qmo/gJ Y884Wf19O34Wb/KXjMF9Oq4PEIGKVqwdH3UNEpuGa9iPUk5GbQvsHc3JVqo29SNSiDc+ KE0m5Z4Evg6EjcTYXEYAQtPuD/P1t1uvumLNDnFlK43sOt9Vs4BKWUfgcm2n3ptRfjFx BvVA== X-Received: by 10.107.161.145 with SMTP id k139mr8286494ioe.41.1426110826334; Wed, 11 Mar 2015 14:53:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.171.101 with HTTP; Wed, 11 Mar 2015 14:53:26 -0700 (PDT) In-Reply-To: <55008342.7070203@cs.ucla.edu> References: <55008342.7070203@cs.ucla.edu> From: Jim Meyering Date: Wed, 11 Mar 2015 14:53:26 -0700 X-Google-Sender-Auth: -Sz_JEcSiK-lTDhX2ov9HMI0ls0 Message-ID: Subject: Re: bug#20088: -a changes whether a match is found To: Paul Eggert Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 20088-done Cc: Andreas Schwab , 20088-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Wed, Mar 11, 2015 at 11:02 AM, Paul Eggert wrote: > On 03/11/2015 10:38 AM, Jim Meyering wrote: >> >> --text (-a) is documented to change only the output, not grep's exit >> status. > > It is documented, albeit too tersely. I tried to improve it by installing > the attached. Thanks, Paul. In which case I'm closing this issue, too. From unknown Fri Jun 20 18:21:01 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 09 Apr 2015 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator