From unknown Sun Jun 22 11:37:52 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#18750 <18750@debbugs.gnu.org> To: bug#18750 <18750@debbugs.gnu.org> Subject: Status: --line-buffered option doesn't work with --files-with-matches Reply-To: bug#18750 <18750@debbugs.gnu.org> Date: Sun, 22 Jun 2025 18:37:52 +0000 retitle 18750 --line-buffered option doesn't work with --files-with-matches reassign 18750 grep submitter 18750 "Louis S." severity 18750 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 16 17:21:36 2014 Received: (at submit) by debbugs.gnu.org; 16 Oct 2014 21:21:36 +0000 Received: from localhost ([127.0.0.1]:46416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XesUK-0003in-04 for submit@debbugs.gnu.org; Thu, 16 Oct 2014 17:21:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58706) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XesPS-0003T2-Ny for submit@debbugs.gnu.org; Thu, 16 Oct 2014 17:16:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XesPR-00060w-Sl for submit@debbugs.gnu.org; Thu, 16 Oct 2014 17:16:34 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36872) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XesPR-00060s-Qh for submit@debbugs.gnu.org; Thu, 16 Oct 2014 17:16:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XesPR-0005NS-1V for bug-grep@gnu.org; Thu, 16 Oct 2014 17:16:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XesPQ-00060U-9w for bug-grep@gnu.org; Thu, 16 Oct 2014 17:16:32 -0400 Received: from mail-ie0-x236.google.com ([2607:f8b0:4001:c03::236]:63163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XesPQ-00060H-3w for bug-grep@gnu.org; Thu, 16 Oct 2014 17:16:32 -0400 Received: by mail-ie0-f182.google.com with SMTP id rp18so4395197iec.13 for ; Thu, 16 Oct 2014 14:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=qn6YAWU/0qQCni500qj/Efa1VmgrHQlhtJelwGlM8eg=; b=d4sJYAh31ftiHkiLZ6tk/dQVX4Lx5dIYZMJqCVwpvxA1WvkR/YvFSPPZciZ5T1Onht 8RYF1V/FSW4CN6qLQjZu4E8Qbp/xoWaM4EZ1L52349k5T9dIrCUob3t6UJmhcFDQeK9I JQfLRASThOaSuFzdsaD0mPmDZw0ZgEPVfuukcnv2FdNTMzcy4Eov+aa8D4rSnp7RcBsD siHTf1bGEncTJoshnNGgUB4GKmZ6/X4B/7c1AuHuCjEoMTXUZFNS6hZoXwCf6XdorgeO zyFoLqxRuxP9vc9ek3wJgMrfYMTAKEbj+cMOlFUuGgpPtmpTIYJaSC0KDTqEWmPhFPR6 gtIg== MIME-Version: 1.0 X-Received: by 10.107.163.142 with SMTP id m136mr4543478ioe.32.1413494190875; Thu, 16 Oct 2014 14:16:30 -0700 (PDT) Received: by 10.107.138.132 with HTTP; Thu, 16 Oct 2014 14:16:30 -0700 (PDT) Date: Thu, 16 Oct 2014 23:16:30 +0200 Message-ID: Subject: --line-buffered option doesn't work with --files-with-matches From: "Louis S." To: bug-grep@gnu.org Content-Type: text/plain; charset=UTF-8 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 X-Mailman-Approved-At: Thu, 16 Oct 2014 17:21:32 -0400 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 (----) Hi, I'm not quite sure this is a bug but it appears that the --line-buffered option has no effect when used in conjunction with --files-with-matches. Here are some tests I ran with grep 2.20: $ time for i in {1..100}; do grep --line-buffered -Rl gnome /usr/ | head -n1 >& /dev/null; done real 0m54.831s user 0m37.077s sys 0m17.550s $ time for i in {1..100}; do grep -Rl gnome /usr/ | head -n1 >& /dev/null; done real 0m54.858s user 0m36.987s sys 0m17.657s $ time for i in {1..100}; do grep --line-buffered -R gnome /usr/ | head -n1 >& /dev/null; done real 0m7.414s user 0m4.727s sys 0m2.613s Please let me know if line-buffering is supposed to work in that case. Regards, Louis From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 17 09:30:57 2014 Received: (at 18750) by debbugs.gnu.org; 17 Oct 2014 13:30:57 +0000 Received: from localhost ([127.0.0.1]:46824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xf7cO-0006nf-Ok for submit@debbugs.gnu.org; Fri, 17 Oct 2014 09:30:57 -0400 Received: from mailgw01.kcn.ne.jp ([61.86.7.208]:39834) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xf7cJ-0006nS-G4 for 18750@debbugs.gnu.org; Fri, 17 Oct 2014 09:30:53 -0400 Received: from imp01 (mailgw5.kcn.ne.jp [61.86.15.231]) by mailgw01.kcn.ne.jp (Postfix) with ESMTP id 317588025C for <18750@debbugs.gnu.org>; Fri, 17 Oct 2014 22:30:49 +0900 (JST) Received: from mail01.kcn.ne.jp ([61.86.6.180]) by imp01 with bizsmtp id 4DWp1p0093t2w9Z01DWpPW; Fri, 17 Oct 2014 22:30:49 +0900 X-OrgRCPT: 18750@debbugs.gnu.org Received: from [10.120.1.74] (i118-21-128-66.s30.a048.ap.plala.or.jp [118.21.128.66]) by mail01.kcn.ne.jp (Postfix) with ESMTPA id AF7DA5A823A; Fri, 17 Oct 2014 22:30:48 +0900 (JST) Date: Fri, 17 Oct 2014 22:30:44 +0900 From: Norihiro Tanaka To: "Louis S." Subject: Re: bug#18750: --line-buffered option doesn't work with --files-with-matches In-Reply-To: References: Message-Id: <20141017223042.85BB.27F6AC2D@kcn.ne.jp> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------_544116010000000085B2_MULTIPART_MIXED_" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.65.07 [ja] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 18750 Cc: 18750@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.0 (/) --------_544116010000000085B2_MULTIPART_MIXED_ Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit "Louis S." wrote: > Hi, I'm not quite sure this is a bug but it appears that the > --line-buffered option has no effect when used in conjunction with > --files-with-matches. > Here are some tests I ran with grep 2.20: > > Please let me know if line-buffering is supposed to work in that case. I see that it's designed, but I think that it's reasonable that output of file names is also line buffered in grep --line-buffered. --------_544116010000000085B2_MULTIPART_MIXED_ Content-Type: text/plain; charset="US-ASCII"; name="0001-grep-line-buffered-for-output-of-file-names-in-grep-.patch" Content-Disposition: attachment; filename="0001-grep-line-buffered-for-output-of-file-names-in-grep-.patch" Content-Transfer-Encoding: base64 RnJvbSA4YTIxOTE0N2NlMTMwZjE3NTYwNWU4NDkzMDdmOWJlODZhYjcxOWI3IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBOb3JpaGlybyBUYW5ha2EgPG5vcml0bmtAa2NuLm5lLmpwPgpE YXRlOiBGcmksIDE3IE9jdCAyMDE0IDIxOjUyOjI5ICswOTAwClN1YmplY3Q6IFtQQVRDSF0gZ3Jl cDogbGluZSBidWZmZXJlZCBmb3Igb3V0cHV0IG9mIGZpbGUgbmFtZXMgaW4gZ3JlcAogLS1saW5l LWJ1ZmZlcmVkCgpOb3cgZ3JlcCAtLWxpbmUtYnVmZmVyZWQgc2V0cyBub3Qgb25seSBtYXRjaGVk IGxpbmVzIGJ1dCBmaWxlIG5hbWVzIHRvCmxpbmUgYnVmZmVyZWQuCgoqIHNyYy9ncmVwLmMgKHN0 YXRpYyBib29sIGxpbmVfYnVmZmVyZWQpOiBSZW1vdmUgdmFyLgoocHJsaW5lKTogUmVtb3ZlIGl0 LgoobWFpbik6IFJlbW92ZSBpdCwgYW5kIHVzZSBzZXR2YnVmKCkuCi0tLQogc3JjL2dyZXAuYyB8 IDYgKy0tLS0tCiAxIGZpbGUgY2hhbmdlZCwgMSBpbnNlcnRpb24oKyksIDUgZGVsZXRpb25zKC0p CgpkaWZmIC0tZ2l0IGEvc3JjL2dyZXAuYyBiL3NyYy9ncmVwLmMKaW5kZXggYTBmMjYyMC4uM2Rl NTY3NCAxMDA2NDQKLS0tIGEvc3JjL2dyZXAuYworKysgYi9zcmMvZ3JlcC5jCkBAIC04MzUsNyAr ODM1LDYgQEAgc3RhdGljIGludCBsaXN0X2ZpbGVzOwkJLyogTGlzdCBtYXRjaGluZyBmaWxlcy4g ICovCiBzdGF0aWMgYm9vbCBub19maWxlbmFtZXM7CS8qIFN1cHByZXNzIGZpbGUgbmFtZXMuICAq Lwogc3RhdGljIGludG1heF90IG1heF9jb3VudDsJLyogU3RvcCBhZnRlciBvdXRwdXR0aW5nIHRo aXMgbWFueQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lcyBmcm9tIGFu IGlucHV0IGZpbGUuICAqLwotc3RhdGljIGJvb2wgbGluZV9idWZmZXJlZDsJLyogVXNlIGxpbmUg YnVmZmVyaW5nLiAgKi8KIHN0YXRpYyBjaGFyICpsYWJlbCA9IE5VTEw7ICAgICAgLyogRmFrZSBm aWxlbmFtZSBmb3Igc3RkaW4gKi8KIAogCkBAIC0xMDk4LDkgKzEwOTcsNiBAQCBwcmxpbmUgKGNo YXIgY29uc3QgKmJlZywgY2hhciBjb25zdCAqbGltLCBjaGFyIHNlcCkKICAgICB9CiAKICAgbGFz dG91dCA9IGxpbTsKLQotICBpZiAobGluZV9idWZmZXJlZCkKLSAgICBmZmx1c2ggKHN0ZG91dCk7 CiB9CiAKIC8qIFByaW50IHBlbmRpbmcgbGluZXMgb2YgdHJhaWxpbmcgY29udGV4dCBwcmlvciB0 byBMSU0uIFRyYWlsaW5nIGNvbnRleHQgZW5kcwpAQCAtMjQwOCw3ICsyNDA0LDcgQEAgbWFpbiAo aW50IGFyZ2MsIGNoYXIgKiphcmd2KQogICAgICAgICBicmVhazsKIAogICAgICAgY2FzZSBMSU5F X0JVRkZFUkVEX09QVElPTjoKLSAgICAgICAgbGluZV9idWZmZXJlZCA9IHRydWU7CisgICAgICAg IHNldHZidWYgKHN0ZG91dCwgTlVMTCwgX0lPTEJGLCAwKTsKICAgICAgICAgYnJlYWs7CiAKICAg ICAgIGNhc2UgTEFCRUxfT1BUSU9OOgotLSAKMi4xLjEKCg== --------_544116010000000085B2_MULTIPART_MIXED_-- From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 18 00:01:15 2014 Received: (at 18750) by debbugs.gnu.org; 18 Oct 2014 04:01:15 +0000 Received: from localhost ([127.0.0.1]:47810 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XfLCd-0005YT-54 for submit@debbugs.gnu.org; Sat, 18 Oct 2014 00:01:15 -0400 Received: from mailgw04.kcn.ne.jp ([61.86.7.211]:47529) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XfLCZ-0005YH-1F for 18750@debbugs.gnu.org; Sat, 18 Oct 2014 00:01:12 -0400 Received: from imp02 (mailgw6.kcn.ne.jp [61.86.15.232]) by mailgw04.kcn.ne.jp (Postfix) with ESMTP id 9C7636C0F14 for <18750@debbugs.gnu.org>; Sat, 18 Oct 2014 13:01:08 +0900 (JST) Received: from mail09.kcn.ne.jp ([61.86.6.188]) by imp02 with bizsmtp id 4U181p00M43QJrh01U18a7; Sat, 18 Oct 2014 13:01:08 +0900 X-OrgRCPT: 18750@debbugs.gnu.org Received: from [10.120.1.30] (i118-21-128-66.s30.a048.ap.plala.or.jp [118.21.128.66]) by mail09.kcn.ne.jp (Postfix) with ESMTPA id 04C501BD0097; Sat, 18 Oct 2014 13:01:07 +0900 (JST) Date: Sat, 18 Oct 2014 13:01:03 +0900 From: Norihiro Tanaka To: "Louis S." Subject: Re: bug#18750: --line-buffered option doesn't work with --files-with-matches In-Reply-To: <20141017223042.85BB.27F6AC2D@kcn.ne.jp> References: <20141017223042.85BB.27F6AC2D@kcn.ne.jp> Message-Id: <20141018130101.E440.27F6AC2D@kcn.ne.jp> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------_5441E56700000000E437_MULTIPART_MIXED_" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.65.07 [ja] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 18750 Cc: 18750@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.0 (/) --------_5441E56700000000E437_MULTIPART_MIXED_ Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit If remove fflush() as the previous patch, unexpected result will be caused in grep -Z. I fixed it. --------_5441E56700000000E437_MULTIPART_MIXED_ Content-Type: text/plain; charset="US-ASCII"; name="0001-grep-line-buffered-for-output-of-file-names-in-grep-.patch" Content-Disposition: attachment; filename="0001-grep-line-buffered-for-output-of-file-names-in-grep-.patch" Content-Transfer-Encoding: base64 RnJvbSBjM2VjMjgyZjk1YjViMWYwZWZlMThmZTcwMzBjNGE5Yzc0ODZkYjAwIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBOb3JpaGlybyBUYW5ha2EgPG5vcml0bmtAa2NuLm5lLmpwPgpE YXRlOiBGcmksIDE3IE9jdCAyMDE0IDIxOjUyOjI5ICswOTAwClN1YmplY3Q6IFtQQVRDSF0gZ3Jl cDogbGluZSBidWZmZXJlZCBmb3Igb3V0cHV0IG9mIGZpbGUgbmFtZXMgaW4gZ3JlcAogLS1saW5l LWJ1ZmZlcmVkCgpOb3cgZ3JlcCAtLWxpbmUtYnVmZmVyZWQgc2V0cyBub3Qgb25seSBtYXRjaGVk IGxpbmVzIGJ1dCBmaWxlIG5hbWVzIHRvCmxpbmUgYnVmZmVyZWQuCgoqIHNyYy9ncmVwLmMgKHN0 YXRpYyBib29sIGxpbmVfYnVmZmVyZWQpOiBSZW1vdmUgdmFyLgoocHJsaW5lKTogUmVtb3ZlIGl0 LgoobWFpbik6IFJlbW92ZSBpdCwgYW5kIHVzZSBzZXRidWYoKS4KLS0tCiBzcmMvZ3JlcC5jIHwg MyArLS0KIDEgZmlsZSBjaGFuZ2VkLCAxIGluc2VydGlvbigrKSwgMiBkZWxldGlvbnMoLSkKCmRp ZmYgLS1naXQgYS9zcmMvZ3JlcC5jIGIvc3JjL2dyZXAuYwppbmRleCBhMGYyNjIwLi42NGE1ZmE1 IDEwMDY0NAotLS0gYS9zcmMvZ3JlcC5jCisrKyBiL3NyYy9ncmVwLmMKQEAgLTgzNSw3ICs4MzUs NiBAQCBzdGF0aWMgaW50IGxpc3RfZmlsZXM7CQkvKiBMaXN0IG1hdGNoaW5nIGZpbGVzLiAgKi8K IHN0YXRpYyBib29sIG5vX2ZpbGVuYW1lczsJLyogU3VwcHJlc3MgZmlsZSBuYW1lcy4gICovCiBz dGF0aWMgaW50bWF4X3QgbWF4X2NvdW50OwkvKiBTdG9wIGFmdGVyIG91dHB1dHRpbmcgdGhpcyBt YW55CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVzIGZyb20gYW4gaW5w dXQgZmlsZS4gICovCi1zdGF0aWMgYm9vbCBsaW5lX2J1ZmZlcmVkOwkvKiBVc2UgbGluZSBidWZm ZXJpbmcuICAqLwogc3RhdGljIGNoYXIgKmxhYmVsID0gTlVMTDsgICAgICAvKiBGYWtlIGZpbGVu YW1lIGZvciBzdGRpbiAqLwogCiAKQEAgLTI0MDgsNyArMjQwNyw3IEBAIG1haW4gKGludCBhcmdj LCBjaGFyICoqYXJndikKICAgICAgICAgYnJlYWs7CiAKICAgICAgIGNhc2UgTElORV9CVUZGRVJF RF9PUFRJT046Ci0gICAgICAgIGxpbmVfYnVmZmVyZWQgPSB0cnVlOworICAgICAgICBzZXR2YnVm IChzdGRvdXQsIE5VTEwsIF9JT0xCRiwgMCk7CiAgICAgICAgIGJyZWFrOwogCiAgICAgICBjYXNl IExBQkVMX09QVElPTjoKLS0gCjIuMS4xCgo= --------_5441E56700000000E437_MULTIPART_MIXED_-- From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 18 19:11:29 2014 Received: (at 18750) by debbugs.gnu.org; 18 Oct 2014 23:11:29 +0000 Received: from localhost ([127.0.0.1]:55327 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xfd9l-0000fg-7Y for submit@debbugs.gnu.org; Sat, 18 Oct 2014 19:11:29 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:60439) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xfd9i-0000fS-Tx for 18750@debbugs.gnu.org; Sat, 18 Oct 2014 19:11:28 -0400 Received: by mail-wi0-f171.google.com with SMTP id em10so4524522wid.4 for <18750@debbugs.gnu.org>; Sat, 18 Oct 2014 16:11:21 -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=E67n6MHcYIy92EBAUHFvOZVWFTtGDuMk9/eGqOJ+3ME=; b=euc/Wrk62lubGiHrQc4TE/L021k3Zy2xEVDiv51kWnbh5D5FsgidGSXJuR4nzmIl9S 6v0LVRFIbzcPtoq+bWBZEMu4VYZSOOpRfwkK7PrFTbxNG/GrcHRRdEy/5+PEkEGgwtUK ylkUORZLzvdy8XOYqmh8b3tHqk7EhfasKu0zY5z1zqn4dopI3ip2Fl9/6cHHkqH/zQcV uI0AMKNMhK949vbpDA8P8kXczwZaE0zFrd+hm2ZrI348RULBIL8/LnZLa/O+AvvzCgFL yBNQHfGO7RJDKOp0Vliz9TGGFj+iDZXF8syZRhE+Lhi6AHPWfi9G1KTsDxgdoTEAU+gB LO1g== X-Received: by 10.180.208.42 with SMTP id mb10mr8602993wic.49.1413673881235; Sat, 18 Oct 2014 16:11:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.86.131 with HTTP; Sat, 18 Oct 2014 16:11:01 -0700 (PDT) In-Reply-To: <20141018130101.E440.27F6AC2D@kcn.ne.jp> References: <20141017223042.85BB.27F6AC2D@kcn.ne.jp> <20141018130101.E440.27F6AC2D@kcn.ne.jp> From: Jim Meyering Date: Sat, 18 Oct 2014 16:11:01 -0700 X-Google-Sender-Auth: RexQJEghAAlg9R4t4CEKAbhuPhM Message-ID: Subject: Re: bug#18750: --line-buffered option doesn't work with --files-with-matches To: Norihiro Tanaka Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18750 Cc: 18750@debbugs.gnu.org, "Louis S." 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 Fri, Oct 17, 2014 at 9:01 PM, Norihiro Tanaka wrote: > If remove fflush() as the previous patch, unexpected result will be > caused in grep -Z. I fixed it. Thanks, but as a stand-alone patch, that makes grep fail to compile, because there is one remaining use of the variable whose declaration is removed. In any case, there is some ambiguity in the documentation about what "line" buffering means with -Z. With -l and -Z, should grep --line-buffered flush after printing each pair? That's what I'd expect. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 18 20:43:28 2014 Received: (at 18750) by debbugs.gnu.org; 19 Oct 2014 00:43:28 +0000 Received: from localhost ([127.0.0.1]:55363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xfeal-00032D-IW for submit@debbugs.gnu.org; Sat, 18 Oct 2014 20:43:27 -0400 Received: from mailgw01.kcn.ne.jp ([61.86.7.208]:42353) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xfeai-00031y-S4 for 18750@debbugs.gnu.org; Sat, 18 Oct 2014 20:43:26 -0400 Received: from imp02 (mailgw6.kcn.ne.jp [61.86.15.232]) by mailgw01.kcn.ne.jp (Postfix) with ESMTP id E5BDB80311 for <18750@debbugs.gnu.org>; Sun, 19 Oct 2014 09:43:17 +0900 (JST) Received: from mail01.kcn.ne.jp ([61.86.6.180]) by imp02 with bizsmtp id 4ojH1p00D3t2w9Z01ojHni; Sun, 19 Oct 2014 09:43:17 +0900 X-OrgRCPT: 18750@debbugs.gnu.org Received: from [10.120.1.51] (i118-21-128-66.s30.a048.ap.plala.or.jp [118.21.128.66]) by mail01.kcn.ne.jp (Postfix) with ESMTPA id 9DE675A82F0; Sun, 19 Oct 2014 09:43:17 +0900 (JST) Date: Sun, 19 Oct 2014 09:43:12 +0900 From: Norihiro Tanaka To: Jim Meyering Subject: Re: bug#18750: --line-buffered option doesn't work with --files-with-matches In-Reply-To: References: <20141018130101.E440.27F6AC2D@kcn.ne.jp> Message-Id: <20141019094312.9216.27F6AC2D@kcn.ne.jp> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------_544305DA00000000922C_MULTIPART_MIXED_" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.65.07 [ja] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 18750 Cc: 18750@debbugs.gnu.org, "Louis S." 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.0 (/) --------_544305DA00000000922C_MULTIPART_MIXED_ Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Jim Meyering wrote: > Thanks, but as a stand-alone patch, that makes grep fail to compile, > because there is one remaining use of the variable whose declaration > is removed. Sorry, I fixed it, and compiled and tested. > In any case, there is some ambiguity in the documentation > about what "line" buffering means with -Z. With -l and -Z, should > grep --line-buffered flush after printing each pair? > That's what I'd expect. I interprete the means as line buffered option `_IOLBF' of setvbuf, and I think that many users will expect the behavior. However, different interpretations might also be present. --------_544305DA00000000922C_MULTIPART_MIXED_ Content-Type: text/plain; charset="US-ASCII"; name="0001-grep-line-buffered-for-output-of-file-names-in-grep-.patch" Content-Disposition: attachment; filename="0001-grep-line-buffered-for-output-of-file-names-in-grep-.patch" Content-Transfer-Encoding: base64 RnJvbSAyMzZjNGI1ZjZiYTNjYmI3NjNjNGFlMWM5MmU5YTFiMDg3ZTkxZmZiIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBOb3JpaGlybyBUYW5ha2EgPG5vcml0bmtAa2NuLm5lLmpwPgpE YXRlOiBGcmksIDE3IE9jdCAyMDE0IDIxOjUyOjI5ICswOTAwClN1YmplY3Q6IFtQQVRDSF0gZ3Jl cDogbGluZSBidWZmZXJlZCBmb3Igb3V0cHV0IG9mIGZpbGUgbmFtZXMgaW4gZ3JlcAogLS1saW5l LWJ1ZmZlcmVkCgpOb3cgZ3JlcCAtLWxpbmUtYnVmZmVyZWQgc2V0cyBub3Qgb25seSBtYXRjaGVk IGxpbmVzIGJ1dCBmaWxlIG5hbWVzIHRvCmxpbmUgYnVmZmVyZWQuCgoqIHNyYy9ncmVwLmMgKHN0 YXRpYyBib29sIGxpbmVfYnVmZmVyZWQpOiBSZW1vdmUgdmFyLgoocHJsaW5lKTogUmVtb3ZlIGl0 LgoobWFpbik6IFJlbW92ZSBpdCwgYW5kIHVzZSBzZXRidWYoKS4KLS0tCiBzcmMvZ3JlcC5jIHwg MSArCiAxIGZpbGUgY2hhbmdlZCwgMSBpbnNlcnRpb24oKykKCmRpZmYgLS1naXQgYS9zcmMvZ3Jl cC5jIGIvc3JjL2dyZXAuYwppbmRleCBhMGYyNjIwLi4zOWMwZDEzIDEwMDY0NAotLS0gYS9zcmMv Z3JlcC5jCisrKyBiL3NyYy9ncmVwLmMKQEAgLTI0MDksNiArMjQwOSw3IEBAIG1haW4gKGludCBh cmdjLCBjaGFyICoqYXJndikKIAogICAgICAgY2FzZSBMSU5FX0JVRkZFUkVEX09QVElPTjoKICAg ICAgICAgbGluZV9idWZmZXJlZCA9IHRydWU7CisgICAgICAgIHNldHZidWYgKHN0ZG91dCwgTlVM TCwgX0lPTEJGLCAwKTsKICAgICAgICAgYnJlYWs7CiAKICAgICAgIGNhc2UgTEFCRUxfT1BUSU9O OgotLSAKMi4xLjEKCg== --------_544305DA00000000922C_MULTIPART_MIXED_-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 20 03:29:32 2014 Received: (at 18750) by debbugs.gnu.org; 20 Oct 2014 07:29:32 +0000 Received: from localhost ([127.0.0.1]:56283 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xg7PI-0007YJ-0j for submit@debbugs.gnu.org; Mon, 20 Oct 2014 03:29:32 -0400 Received: from mail-ie0-f176.google.com ([209.85.223.176]:36685) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xg7PF-0007Y3-9E for 18750@debbugs.gnu.org; Mon, 20 Oct 2014 03:29:30 -0400 Received: by mail-ie0-f176.google.com with SMTP id rp18so4015580iec.7 for <18750@debbugs.gnu.org>; Mon, 20 Oct 2014 00:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=RNIjgxgKoPGGQkz9tLokS0/zvjenUxZrt283sthKhNQ=; b=piXNQWpRgMZB6DdasdRRJLDe4hB2cMZBUcUuRtjQkmu7DcmDpKthWdNDbRgOyCNzBi 0yPLaHFP6rpfUC1gmJsHxgsxNCWprlKrcN8f8t5JZWrs7qFojGISXUdqmxUdZaRndW6G U18xuaYOe4K6XXXw9KAAO0U7ITGVInPslmYeNIUAZ2EJl+Y1cf+ukW429+xDcvSk4QvC m2BeEH+RIZ0NrD7uvBdmOhqVGk7lZxlKQCK47ciqXADcmfAntU4DUrfz4RjzGHF0nmlf C6TKKUbao0ZRi4vbHknP9v4gbA0G2hXOzHl4N+x7/LwVl4DwjpJ6g86+sQo+ho6X5MuH EMag== MIME-Version: 1.0 X-Received: by 10.42.66.143 with SMTP id p15mr25222179ici.11.1413790163094; Mon, 20 Oct 2014 00:29:23 -0700 (PDT) Received: by 10.107.138.132 with HTTP; Mon, 20 Oct 2014 00:29:23 -0700 (PDT) In-Reply-To: <20141019094312.9216.27F6AC2D@kcn.ne.jp> References: <20141018130101.E440.27F6AC2D@kcn.ne.jp> <20141019094312.9216.27F6AC2D@kcn.ne.jp> Date: Mon, 20 Oct 2014 09:29:23 +0200 Message-ID: Subject: Re: bug#18750: --line-buffered option doesn't work with --files-with-matches From: Louis Sautier To: Norihiro Tanaka Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18750 Cc: 18750@debbugs.gnu.org, Jim Meyering 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 (/) I have no issue with this behaviour, I just wish one could have buffered null-separated output as well. On 19 October 2014 02:43, Norihiro Tanaka wrote: > Jim Meyering wrote: >> Thanks, but as a stand-alone patch, that makes grep fail to compile, >> because there is one remaining use of the variable whose declaration >> is removed. > > Sorry, I fixed it, and compiled and tested. > >> In any case, there is some ambiguity in the documentation >> about what "line" buffering means with -Z. With -l and -Z, should >> grep --line-buffered flush after printing each pair? >> That's what I'd expect. > > I interprete the means as line buffered option `_IOLBF' of setvbuf, and > I think that many users will expect the behavior. However, different > interpretations might also be present. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 20 19:54:38 2014 Received: (at 18750) by debbugs.gnu.org; 20 Oct 2014 23:54:38 +0000 Received: from localhost ([127.0.0.1]:57579 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XgMmb-0003rY-Pk for submit@debbugs.gnu.org; Mon, 20 Oct 2014 19:54:38 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:38632) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XgMmZ-0003rI-7a for 18750@debbugs.gnu.org; Mon, 20 Oct 2014 19:54:36 -0400 Received: by mail-wg0-f47.google.com with SMTP id x13so85133wgg.30 for <18750@debbugs.gnu.org>; Mon, 20 Oct 2014 16:54:29 -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=xv1DcloU/174wTgJao1Q1mYgArc5qrUJs9Mv2rz9pZg=; b=Dmoh1S9cV+CecmY3QI8kX26npl2IzXhutSl/bzSmwPTlLXIukatyURiX1YV/lXD2eR uRyL4/hcK7OqMsZYLowCt0ti86ZBJkJJiU2n4XiDzoFmUTmm5TcNDozYwAqlXJ3WVFvW jovPPA985DDI+xnxmzU34J9vwkBNh+coDI1CHZa1khr2c3MIvJhm0eteln0vDv5sZM1I uP1Sk/r6ICgaXtmOhikx45UtbPLZqEJgfNeBCQJ6rm359IgYSoloONONerc0k2xQ3Q2C QkwktYAPQBBe2XJa5UjmrRccTa5oF9nocu3h50etQmA+YHhant9uN0kaf9DIqcYGnp3i wStw== X-Received: by 10.194.90.175 with SMTP id bx15mr36669319wjb.25.1413849269199; Mon, 20 Oct 2014 16:54:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.86.131 with HTTP; Mon, 20 Oct 2014 16:54:07 -0700 (PDT) In-Reply-To: References: <20141018130101.E440.27F6AC2D@kcn.ne.jp> <20141019094312.9216.27F6AC2D@kcn.ne.jp> From: Jim Meyering Date: Mon, 20 Oct 2014 16:54:07 -0700 X-Google-Sender-Auth: 3mKcqiAUlpDw6yr0e2Np_3C5PCQ Message-ID: Subject: Re: bug#18750: --line-buffered option doesn't work with --files-with-matches To: Louis Sautier Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18750 Cc: 18750@debbugs.gnu.org, Norihiro Tanaka 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 Mon, Oct 20, 2014 at 12:29 AM, Louis Sautier wrote: > I have no issue with this behaviour, I just wish one could have > buffered null-separated output as well. > > On 19 October 2014 02:43, Norihiro Tanaka wrote: >> Jim Meyering wrote: >>> Thanks, but as a stand-alone patch, that makes grep fail to compile, >>> because there is one remaining use of the variable whose declaration >>> is removed. >> >> Sorry, I fixed it, and compiled and tested. >> >>> In any case, there is some ambiguity in the documentation >>> about what "line" buffering means with -Z. With -l and -Z, should >>> grep --line-buffered flush after printing each pair? >>> That's what I'd expect. >> >> I interprete the means as line buffered option `_IOLBF' of setvbuf, and >> I think that many users will expect the behavior. However, different >> interpretations might also be present. Thanks for the feedback. What is your use case? As I said above, I too would have expected -Z -l --line-buffered to flush after each pair. Though note that the larger change would have to update documentation clarifying that this also applies to output that may not contain any newline. It might even prompt the addition of a new option name, --buffered, as a more-aptly-named synonym for --line-buffered. P.S., please do not "top post", i.e., reply after the bottom of the quoted text, as I have done. From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 21 05:27:47 2014 Received: (at 18750) by debbugs.gnu.org; 21 Oct 2014 09:27:47 +0000 Received: from localhost ([127.0.0.1]:57789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XgVjH-0002Xg-26 for submit@debbugs.gnu.org; Tue, 21 Oct 2014 05:27:47 -0400 Received: from mail-ie0-f171.google.com ([209.85.223.171]:46446) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XgVjE-0002XN-JJ for 18750@debbugs.gnu.org; Tue, 21 Oct 2014 05:27:46 -0400 Received: by mail-ie0-f171.google.com with SMTP id x19so197903ier.30 for <18750@debbugs.gnu.org>; Tue, 21 Oct 2014 02:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=1qu/4honTPeySm5XofQyWTYdwJp3Ts6Kp9tgDIl8BHw=; b=lEn0AipJ8O7yU7SDnX+HaafsRnAvYGlYhz1IRViSZ5Y7K/bxlXCRVQIe4ZWMixM3Ll v/os/Albx8cug8iamVQ2pJlGTSND2VoDcXjOYFtJe7oZUr+HzAF/EPDzq5X5UkBat5U5 xBqnz16Z/I+GsIYBGJrQhkr/m0EFEvGzAESyqV2UJh++haAEz2ecIYPYbiCEotbaAlxL xcIWZoTf87WhRUh/HIjdmVsxFphyM2Et9Glvqb5gs+ANRzEBGXGktjXvhPVgaKTwdPh9 Zj2ZrvXsU4j9jydBSvs6n4P2kbaTE5wLJP6swQ9mxJoaPAFWzsSCSIwt/3XALobDVf6L jnKg== MIME-Version: 1.0 X-Received: by 10.50.128.163 with SMTP id np3mr24674858igb.28.1413883658724; Tue, 21 Oct 2014 02:27:38 -0700 (PDT) Received: by 10.107.138.132 with HTTP; Tue, 21 Oct 2014 02:27:38 -0700 (PDT) In-Reply-To: References: <20141018130101.E440.27F6AC2D@kcn.ne.jp> <20141019094312.9216.27F6AC2D@kcn.ne.jp> Date: Tue, 21 Oct 2014 11:27:38 +0200 Message-ID: Subject: Re: bug#18750: --line-buffered option doesn't work with --files-with-matches From: Louis Sautier To: Jim Meyering Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18750 Cc: 18750@debbugs.gnu.org, Norihiro Tanaka 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 21 October 2014 01:54, Jim Meyering wrote: > On Mon, Oct 20, 2014 at 12:29 AM, Louis Sautier wrote: >> I have no issue with this behaviour, I just wish one could have >> buffered null-separated output as well. >> >> On 19 October 2014 02:43, Norihiro Tanaka wrote: >>> Jim Meyering wrote: >>>> Thanks, but as a stand-alone patch, that makes grep fail to compile, >>>> because there is one remaining use of the variable whose declaration >>>> is removed. >>> >>> Sorry, I fixed it, and compiled and tested. >>> >>>> In any case, there is some ambiguity in the documentation >>>> about what "line" buffering means with -Z. With -l and -Z, should >>>> grep --line-buffered flush after printing each pair? >>>> That's what I'd expect. >>> >>> I interprete the means as line buffered option `_IOLBF' of setvbuf, and >>> I think that many users will expect the behavior. However, different >>> interpretations might also be present. > > Thanks for the feedback. What is your use case? > As I said above, I too would have expected -Z -l --line-buffered to flush > after each pair. > > Though note that the larger change would > have to update documentation clarifying that this also applies > to output that may not contain any newline. It might even prompt > the addition of a new option name, --buffered, as a > more-aptly-named synonym for --line-buffered. > > P.S., please do not "top post", i.e., reply after the bottom of the > quoted text, as I have done. I think --buffered would be more clear, yes. I would use such an option to run commands on batches of files found by grep such as: grep --buffered -RlZ pattern /path | xargs -0 -n 100 rm From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 31 03:29:57 2015 Received: (at 18750-done) by debbugs.gnu.org; 31 Dec 2015 08:29:57 +0000 Received: from localhost ([127.0.0.1]:50912 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aEYcP-0004jw-0t for submit@debbugs.gnu.org; Thu, 31 Dec 2015 03:29:57 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41290) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aEYcM-0004jj-MS for 18750-done@debbugs.gnu.org; Thu, 31 Dec 2015 03:29:55 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2486E160ED0; Thu, 31 Dec 2015 00:29:48 -0800 (PST) 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 lUMfGidb7ncW; Thu, 31 Dec 2015 00:29:47 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1B585160ED6; Thu, 31 Dec 2015 00:29:47 -0800 (PST) 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 53UwcvFO2dIu; Thu, 31 Dec 2015 00:29:47 -0800 (PST) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id EAF9A160ED0; Thu, 31 Dec 2015 00:29:46 -0800 (PST) To: 18750-done@debbugs.gnu.org From: Paul Eggert Subject: Re: --line-buffered option doesn't work with --files-with-matches Organization: UCLA Computer Science Department Message-ID: <5684E77A.5000808@cs.ucla.edu> Date: Thu, 31 Dec 2015 00:29:46 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080508010407060507010905" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 18750-done Cc: "Louis S." , Norihiro Tanaka 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.0 (/) This is a multi-part message in MIME format. --------------080508010407060507010905 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for the bug report. It also seems to me that --line-buffered should apply to nulls, not newlines, when -z is used. Also, there are a couple of other places where stdout should get flushed after a newline. Perhaps we should use setvbuf instead (is it faster?) when -z is not also used, but right now I just want to get the bug fixed for the next release, so I installed the attached, more-conservative, patch, and am marking this bug as done. --------------080508010407060507010905 Content-Type: text/x-diff; name="0001-grep-fix-l-line-buffer-bug.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-grep-fix-l-line-buffer-bug.patch" >From 01304357cbfd655ebe4c27f5ccde8d07c2f3bbb1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 31 Dec 2015 00:20:54 -0800 Subject: [PATCH] grep: fix -l --line-buffer bug Problem reported by Louis Sautier in: http://bugs.gnu.org/18750 * NEWS: Document this. * src/grep.c (grep, grepdesc): If --line-buffered, flush stdout after outputting newline (or null byte, if applicable). --- NEWS | 3 +++ src/grep.c | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 4bf408c..b451d76 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,9 @@ GNU grep NEWS -*- outline -*- This partly reverts the --exclude-related change in 2.22. [bug introduced in grep-2.22] + --line-buffer is no longer ineffective when combined with -l + [bug introduced in grep-2.5] + * Noteworthy changes in release 2.22 (2015-11-01) [stable] diff --git a/src/grep.c b/src/grep.c index 03a1bff..06f3345 100644 --- a/src/grep.c +++ b/src/grep.c @@ -1481,7 +1481,11 @@ grep (int fd, struct stat const *st) done_on_match = done_on_match_0; out_quiet = out_quiet_0; if ((has_nulls || encoding_error_output) && !out_quiet && nlines != 0) - printf (_("Binary file %s matches\n"), filename); + { + printf (_("Binary file %s matches\n"), filename); + if (line_buffered) + fflush (stdout); + } return nlines; } @@ -1725,6 +1729,8 @@ grepdesc (int desc, bool command_line) fputc (0, stdout); } printf ("%" PRIdMAX "\n", count); + if (line_buffered) + fflush (stdout); } status = !count; @@ -1732,6 +1738,8 @@ grepdesc (int desc, bool command_line) { print_filename (); fputc ('\n' & filename_mask, stdout); + if (line_buffered) + fflush (stdout); } if (desc == STDIN_FILENO) -- 2.5.0 --------------080508010407060507010905-- From unknown Sun Jun 22 11:37:52 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, 28 Jan 2016 12: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