Date: Wed, 04 Aug 2010 11:06:15 -0700 From: Xin LI <delphij@delphij.net> To: Gabor Kovesdan <gabor@FreeBSD.org> Cc: poyopoyo@puripuri.plala.or.jp, current@FreeBSD.org Subject: Re: bsdgrep does not work with tail -f | grep combination Message-ID: <4C59AC17.5000200@delphij.net> In-Reply-To: <4C585E44.5030608@FreeBSD.org> References: <86eiefhalp.wl%poyopoyo@puripuri.plala.or.jp> <4C585E44.5030608@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <delphij@delphij.net> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C59AC17.5000200>