From owner-freebsd-current@FreeBSD.ORG Wed Aug 4 18:35:31 2010 Return-Path: Delivered-To: current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E28761065674; Wed, 4 Aug 2010 18:35:30 +0000 (UTC) (envelope-from bakul@bitblocks.com) Received: from mail.bitblocks.com (bitblocks.com [64.142.15.60]) by mx1.freebsd.org (Postfix) with ESMTP id C526C8FC1B; Wed, 4 Aug 2010 18:35:30 +0000 (UTC) Received: from bitblocks.com (localhost.bitblocks.com [127.0.0.1]) by mail.bitblocks.com (Postfix) with ESMTP id 579AF5B87; Wed, 4 Aug 2010 11:18:02 -0700 (PDT) To: Gabor Kovesdan In-reply-to: Your message of "Tue, 03 Aug 2010 20:21:56 +0200." <4C585E44.5030608@FreeBSD.org> References: <86eiefhalp.wl%poyopoyo@puripuri.plala.or.jp> <4C585E44.5030608@FreeBSD.org> Comments: In-reply-to Gabor Kovesdan message dated "Tue, 03 Aug 2010 20:21:56 +0200." Date: Wed, 04 Aug 2010 11:18:02 -0700 From: Bakul Shah Message-Id: <20100804181802.579AF5B87@mail.bitblocks.com> Cc: poyopoyo@puripuri.plala.or.jp, current@FreeBSD.org Subject: Re: bsdgrep does not work with tail -f | grep combination X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Aug 2010 18:35:31 -0000 On Tue, 03 Aug 2010 20:21:56 +0200 Gabor Kovesdan wrote: > Em 2010.08.03. 19:25, poyopoyo@puripuri.plala.or.jp escreveu: > > Hi, > > > > It seems bsdgrep does not work when piped from tail -f. > > I'm running r210728. > > > > term0$ jot 10> /tmp/1 > > term0$ tail -f /tmp/1 | grep 0 > > [no output] > > > > otherterm$ jot 10>> /tmp/1 > > [no output to term0] > > > > ===== > > > > with GNU grep: > > > > term0$ tail -f /tmp/1 | gnugrep 0 > > 10 > > otherterm$ jot 10>> /tmp/1 > > [on term0] > > 10 > > 10 > > > I've checked on 8.0 and GNU grep doesn't output anything either for me. > If you use tail -f, you will enter more lines and end it with EOF, won't > you? And then BSD grep will process the input and print out matches. I > don't think it's bad behaviour in itself but if you can explain why you > think it's bad I'm willing to change it. This is more fundamental, not just limited to grep. tail -f never closes its stdout channel so the next process in the pipeline will never seen an EOF on its stdin and must continue processing its input. Try this: rm -f /tmp/1; touch /tmp/1 tail -f /tmp/1 | cat & while sleep 1; do date >> /tmp/1; done Notice how cat doesn't quit. In fact tail -f /tmp/1 | bsdgrep '' must behave exactly the same as tail -f /tmp/1 | cat and so must this: tail -f /tmp/1 | cat | bsdgrep '' bsdgrep when used this way doesn't quit but doesn't do anything either (including printing what tail -f spits out from existing file data). This is just a bug.