Refactor tail continued V2#5173
Closed
tertsdiepraam wants to merge 4 commits intouutils:mainfrom
Closed
Conversation
Closed
|
GNU testsuite comparison: |
5a63696 to
259eac8
Compare
Collaborator
Author
|
This is how I think we should approach this PR:
|
cakebaker
reviewed
Aug 28, 2023
cakebaker
reviewed
Aug 28, 2023
cakebaker
reviewed
Aug 28, 2023
cakebaker
reviewed
Aug 28, 2023
cakebaker
reviewed
Aug 28, 2023
cakebaker
reviewed
Aug 28, 2023
cakebaker
reviewed
Aug 28, 2023
cakebaker
reviewed
Aug 28, 2023
…with error propagation ... Return io::Result from methods in chunks.rs to be able to replace unwraps with error propagation and return the bytes read from the source so far. Store how many bytes are read in LinesChunkBuffer. Fixes: tail does not output anything when there's no newline in the source and the `--follow` option is given. Flush the buffered writer after a write explicitly. Simplify the BytesChunkBuffer::fill and LinesChunkBuffer::fill methods and make use of some new helper methods in these structs. Add more unit tests for structs in chunks.rs
tail.rs: * Change and simplify the control flow to try to open the input or file first and then react appropriately on errors. Note this also fixes some misbehavior on macos when a fifo pointed to a directory and other minor related issues. * Differentiate between read and write errors to exit on write errors. Read errors in contrast are not fatal and are handled like the other `TailError` types in the `TailErrorHandler` in the newly created error.rs module. * Return `Result<u64, TailError>` from unbounded_tail and bounded_tail. The Ok result (bytes read and printed) is currently not used but can be used later in the follow module. * Fix printing of Fifos multiple times. For example `tail - - < file` printed the content of the file twice). Fifos should behave like other standard input in such cases. follow/files.rs: Add "untailable" files separately in an own method to the set of watched files. paths.rs: * Remove the resolve method and replace the workaround with the more reliable open method which also differentiates between a fifo and a pipe in case of stdin. It uses an improved version of `FileExtTail::is_seekable` to be able to do so. * Cleanup the redundant `stdin_is_bad_fd` function
259eac8 to
0133ee7
Compare
Contributor
|
no activity for a while, closing |
Collaborator
Author
|
Well, it was ready for review the whole time 😄 But yeah even though I tried to save some changes I don't think it was worth it. Good call! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resurrection of #3952, which I'll close in favor of this PR.
Still a draft because I'll need to look at the commit about tests still. The rest should be properly rebased and cleaned up (even though there was little cleaning up to do).
I've opted to make a separate PR, because the changes I made required some intensive surgery (e.g. removing commits).