From owner-freebsd-current@FreeBSD.ORG Wed Aug 4 18:06:27 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 7D4FB1065670; Wed, 4 Aug 2010 18:06:27 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [IPv6:2001:470:a803::1]) by mx1.freebsd.org (Postfix) with ESMTP id 22F198FC18; Wed, 4 Aug 2010 18:06:27 +0000 (UTC) Received: from mail.geekcn.org (tarsier.geekcn.org [211.166.10.233]) by tarsier.geekcn.org (Postfix) with ESMTP id E16C1A5F4A6; Thu, 5 Aug 2010 02:06:25 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([211.166.10.233]) by mail.geekcn.org (mail.geekcn.org [211.166.10.233]) (amavisd-new, port 10024) with LMTP id 6kK+9wPLUzb4; Thu, 5 Aug 2010 02:06:20 +0800 (CST) Received: from delta.delphij.net (drawbridge.ixsystems.com [206.40.55.65]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTPSA id 0C4F8A5F4A8; Thu, 5 Aug 2010 02:06:18 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:cc:subject:references:in-reply-to: x-enigmail-version:openpgp:content-type; b=hhh0ZBFW2dA0tBG6uQ+ML6N/UNYQ/xgpoEP5eECLBMkamSgoqIHF2YJjRjm31Eo7l +BacCZL+HFD9EL37/6q9g== Message-ID: <4C59AC17.5000200@delphij.net> Date: Wed, 04 Aug 2010 11:06:15 -0700 From: Xin LI Organization: The Geek China Organization User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.1.11) Gecko/20100721 Thunderbird/3.0.6 ThunderBrowse/3.3.1 MIME-Version: 1.0 To: Gabor Kovesdan References: <86eiefhalp.wl%poyopoyo@puripuri.plala.or.jp> <4C585E44.5030608@FreeBSD.org> In-Reply-To: <4C585E44.5030608@FreeBSD.org> X-Enigmail-Version: 1.0.1 OpenPGP: id=3FCA37C1; url=http://www.delphij.net/delphij.asc Content-Type: multipart/mixed; boundary="------------090500050607070903040508" 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 Reply-To: d@delphij.net 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:06:27 -0000 This is a multi-part message in MIME format. --------------090500050607070903040508 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 2010/08/03 11:21, Gabor Kovesdan wrote: > 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. I'm able to reproduce the GNU behavior on 9.0-CURRENT which is IMO right. I think we need to break at the line end to provide better interactivity (the current code seems to do it (buffer is not full && !eof), while what we wanted is (buffer is not full && !eof && !eol). The attached patch should fix this but I have not yet thoroughly tested it due to job work. Cheers, - -- Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (FreeBSD) iQEcBAEBCAAGBQJMWawXAAoJEATO+BI/yjfBigMIAM2PHLXm2Qz4Kzhd8y+NYc2S VKJVzNv6DAVMyqCXbezp6d+Qt4sls31uvFhizS9e6HZdUolqV4/m5AiM9UcF2wK4 i49PoQPSBs3Gpp0fuM4kxlZCp843ABkZfeYr2oFZluEA144jlA2bwrX598hmo2Ge ikpljC/4R8e6TOdTNobcV4jTeHCcGYZv5nmCmODY4DZoGkFjXNQJL/zpHLYgaNyn 0j9TZ1okhaG/jLATlc+UhtyetB/wkN8VGNDyxQNg4a7iMw0xkqjoxMVpsoF4uoXS YOcSEOXuvwHxs6jlkH7z0u06bmqqdv7Okw4OSANvGN35AuB7OQDrJWHdPBS9DZA= =pZe0 -----END PGP SIGNATURE----- --------------090500050607070903040508 Content-Type: text/plain; name="grep.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="grep.diff" Index: file.c =================================================================== --- file.c (revision 210851) +++ file.c (working copy) @@ -139,7 +139,7 @@ while (i < bufsiz) { ch = grep_fgetc(f); - if (ch == EOF) + if (ch == EOF || ch == '\n') break; binbuf[i++] = ch; } --------------090500050607070903040508--