bsdgrep does not work with tail -f | grep combination
Xin LI
delphij at delphij.net
Wed Aug 4 18:06:27 UTC 2010
-----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 at 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-----
-------------- next part --------------
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;
}
More information about the freebsd-current
mailing list