From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 03 09:28:36 2017 Received: (at submit) by debbugs.gnu.org; 3 Aug 2017 13:28:36 +0000 Received: from localhost ([127.0.0.1]:39380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddGB1-0007TQ-QA for submit@debbugs.gnu.org; Thu, 03 Aug 2017 09:28:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddGAz-0007TC-KO for submit@debbugs.gnu.org; Thu, 03 Aug 2017 09:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddGAt-0000ZT-3t for submit@debbugs.gnu.org; Thu, 03 Aug 2017 09:28:28 -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,T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33405) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ddGAt-0000ZA-1c for submit@debbugs.gnu.org; Thu, 03 Aug 2017 09:28:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddGAr-0007QL-Tu for bug-grep@gnu.org; Thu, 03 Aug 2017 09:28:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddGAo-0000U5-81 for bug-grep@gnu.org; Thu, 03 Aug 2017 09:28:25 -0400 Received: from mx1.riseup.net ([198.252.153.129]:39157) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ddGAo-0000S1-0S for bug-grep@gnu.org; Thu, 03 Aug 2017 09:28:22 -0400 Received: from piha.riseup.net (unknown [10.0.1.163]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.riseup.net (Postfix) with ESMTPS id 59EF21A1AEB; Thu, 3 Aug 2017 13:28:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1501766900; bh=Dvy93STU+nB9WPt2B5wQXlh4CGPOGfvncCS7P3jiFtI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iKqdFb7dSQk3C1tjfy9RbetQjE/GO5wdO8LMpz6jSe2FKUIPxk8lexULlwWj16pvi KtepJkCtx0Am1kSHym4D6i64INcRFZ0TqtoCdhgXM0iBJVEbys9VU6tOCYsNxa/1HC vgsaQ4SYQqyuN+qR/Y1f0TYqvms40t+PrDv7Zen0= Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: santiagorr@riseup.net) by (piha) with ESMTPSA id AF7251DC1C0 Date: Thu, 3 Aug 2017 15:28:14 +0200 From: "Santiago R.R." To: bug-grep@gnu.org Subject: grep -o fails to count empty lines (Debain Bug #532541) Message-ID: <20170803132814.w3y43z43cqhtkdus@riseup.net> References: <4CC3F39E.6030501@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4CC3F39E.6030501@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit Cc: 532541@bugs.debian.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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.1 (----) (Sorry if it's already filed, but I am unable to find it in the bug archives) Hi, I'd like to forward this bug reported to Debian some years ago. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=532541 It still happens in 3.1. Quoting the original report: When grepping for empty lines in a text file, grep works correctly in most cases: ~$ grep ^$ myfile.txt ~$ grep -n ^$ myfile.txt 11: 15: 19: 21: 22: However the -o option, which is supposed to return only the matching parts of the search, fails: ~$ grep -o ^$ myfile.txt ~$ grep -no ^$ myfile.txt ~$ Thanks, Santiago From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 03 16:17:04 2017 Received: (at 27931-done) by debbugs.gnu.org; 3 Aug 2017 20:17:04 +0000 Received: from localhost ([127.0.0.1]:40402 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddMYK-0000D4-Hm for submit@debbugs.gnu.org; Thu, 03 Aug 2017 16:17:04 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33946) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddMYH-0000CV-0z for 27931-done@debbugs.gnu.org; Thu, 03 Aug 2017 16:17:01 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2D3B91606FD; Thu, 3 Aug 2017 13:16:54 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id x1_JJFG6PPvj; Thu, 3 Aug 2017 13:16:53 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5A26216073B; Thu, 3 Aug 2017 13:16:53 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 9d2A-qmaL_Wp; Thu, 3 Aug 2017 13:16:53 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 31EAA1606FD; Thu, 3 Aug 2017 13:16:53 -0700 (PDT) Subject: Re: bug#27931: grep -o fails to count empty lines (Debain Bug #532541) To: "Santiago R.R." , 27931-done@debbugs.gnu.org References: <4CC3F39E.6030501@gnu.org> <20170803132814.w3y43z43cqhtkdus@riseup.net> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <5d55317a-429d-1bf9-6ea3-86e780424b79@cs.ucla.edu> Date: Thu, 3 Aug 2017 13:16:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170803132814.w3y43z43cqhtkdus@riseup.net> Content-Type: multipart/mixed; boundary="------------49C93947329B7FFEB0DD64DE" Content-Language: en-US X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 27931-done Cc: Greg Trounson , Paolo Bonzini , Kai YU , 532541@bugs.debian.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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 (/) This is a multi-part message in MIME format. --------------49C93947329B7FFEB0DD64DE Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 08/03/2017 06:28 AM, Santiago R.R. wrote: > the -o option, which is supposed to return only the matching > parts of the search, fails: It's not failing. It's behaving as documented: -o outputs only nonempty matches. Otherwise, commands like 'grep -o "a*"' would output a separate line for each byte in the input. Although this behavior for -o is longstanding and is documented in the manual, it's not in the grep --help output so that's an oversight. I installed the attached to fix grep --help, and am closing the bug report on the GNU side. Users who want to match empty lines can use 'grep "^$"', which is what I'd expect them to do anyway (-o would be superfluous there even if it included empty matches). --------------49C93947329B7FFEB0DD64DE Content-Type: text/x-patch; name="0001-doc-improve-o-help.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-doc-improve-o-help.patch" >From fe06a81c1fdaeda10bfdde82b43e2b18bfd1de5e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 3 Aug 2017 13:07:01 -0700 Subject: [PATCH] doc: improve -o help * src/grep.c (usage): Document that -o outputs only nonempty matches (Bug#27931). --- src/grep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grep.c b/src/grep.c index 8d22aec..dd338d9 100644 --- a/src/grep.c +++ b/src/grep.c @@ -1949,7 +1949,7 @@ Output control:\n\ --label=LABEL use LABEL as the standard input file name prefix\n\ ")); printf (_("\ - -o, --only-matching show only the part of a line matching PATTERN\n\ + -o, --only-matching show only nonempty parts of lines matching PATTERN\n\ -q, --quiet, --silent suppress all normal output\n\ --binary-files=TYPE assume that binary files are TYPE;\n\ TYPE is 'binary', 'text', or 'without-match'\n\ -- 2.13.3 --------------49C93947329B7FFEB0DD64DE-- From unknown Thu Aug 14 21:54:50 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 01 Sep 2017 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