-
Notifications
You must be signed in to change notification settings - Fork 119
buffered output #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I had been thinking about improving this to get rid of the artifact, but have not yet found time to work on it. A good thing now is that ugrep "understands" the difference between a line-based regex and a multi-line regex, which is internally used for certain speed optimizations. The line will be completed, but it takes until the next match to do so or until EOF, whichever comes first. This is an artifact of the built-in multiline matching capability of ugrep. Multiline matching can only work properly if the engine can safely flush the current line and move the next without skipping a potential match that spans the current line matched to the next line and beyond (which may not have been read yet). For example, the pattern Note that by contrast, GNU grep is a line-oriented matcher, so it consumes line-by-line to find matching lines (in essence). I don't want to restrict ugrep's |
I should add that option |
I'm not satisfied either. This should and can be improved. At least when a non-matching line arrives in the buffer right after a line with a match that is displayed, then the complete matching line should be displayed, i.e. not dangle unfinished until another matching line arrives (much) later (as is the case right now.) This is what I have in mind, hope it is acceptable:
Note the first point: this does not delay piping through ugrep such as Option |
Quick update. The dev implementation is done, except for refactoring the code, perform additional verification and testing, and by addressing one case I am not happy with yet (it is not perfectly following the proposed points). Again, we don't need Ugrep is also already made smart enough to immediately show matches and flush output when matches are made on standard input from a character device or a pipe, e.g. to follow input with |
Still not 100% happy with the ugrep update I'm working on to release. The stdin pipe to ugrep behavior should be the same as GNU grep. That's not yet the case, because ugrep may quit under certain circumstances (e.g. max matches were found), whereas GNU grep keeps draining stdin until EOF (if that ever comes). So let's do the same. |
Implementation and testing are complete. Results and performance look good. The speed of input-following, with All matching lines are displayed immediately when color is not used. With color, the matching line is completed when the next line arrives in the buffer, as I've described above. The reason is that the ugrep regex engine is not line based like GNU grpe, but is inherently multi-line matching. It would be possible to exactly replicate GNU grep, but this requires separate code just for following the input line-by-line. I think that is overkill, but if necessary it can be done. Will release an update soon. |
Hi,
No sure if this is a bug, or just a lack of me understanding the configuration options (so bear with me)
ugrep 7.3.0 amd64-portbld-freebsd14.1 +avx512; -P:pcre2jit; -z:zlib,bzip2,lzma,lz4,zstd,brotli,bzip3,7z,tar/pax/cpio/zip
I often need to grep a stream to stdin, e.g. varnishlog or just a simple tail - and it seems I get my grep but not remainder of the line, e.g.
as you can see the last line does not print fully, until a new line is matched..
I've tried with and without
--line-buffered
- no change.The text was updated successfully, but these errors were encountered: