Skip to content
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

Fix tail -<number> does not work #2747

Merged
merged 4 commits into from
Nov 19, 2021
Merged

Fix tail -<number> does not work #2747

merged 4 commits into from
Nov 19, 2021

Conversation

Smicry
Copy link
Contributor

@Smicry Smicry commented Nov 14, 2021

echo "a\nb" | ./target/debug/tail -1

b

@sylvestre
Copy link
Contributor

Looks great. Could you please also add high level tests in:
https:/uutils/coreutils/blob/master/tests/by-util/test_tail.rs

And make sure that the coverage is great!

@sylvestre
Copy link
Contributor

clippy is also complaining with:


error: field assignment outside of initializer for an instance created with Default::default()
   --> src/uu/tail/src/tail.rs:104:9
    |
104 |         settings.follow = matches.is_present(options::FOLLOW);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::field-reassign-with-default` implied by `-D warnings`
note: consider initializing the variable with `Settings { follow: matches.is_present(options::FOLLOW), ..Default::default() }` and removing relevant reassignments
   --> src/uu/tail/src/tail.rs:102:9
    |
102 |         let mut settings: Settings = Default::default();
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default

error: this expression borrows a reference (`&Settings`) that is immediately dereferenced by the compiler
   --> src/uu/tail/src/tail.rs:200:41
    |
200 |             unbounded_tail(&mut reader, &settings);
    |                                         ^^^^^^^^^ help: change this to: `settings`
    |
    = note: `-D clippy::needless-borrow` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

error: this expression borrows a reference (`&Settings`) that is immediately dereferenced by the compiler
   --> src/uu/tail/src/tail.rs:232:41
    |
232 |                 bounded_tail(&mut file, &settings);
    |                                         ^^^^^^^^^ help: change this to: `settings`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

error: this expression borrows a reference (`&Settings`) that is immediately dereferenced by the compiler
   --> src/uu/tail/src/tail.rs:239:45
    |
239 |                 unbounded_tail(&mut reader, &settings);
    |                                             ^^^^^^^^^ help: change this to: `settings`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

error: this expression borrows a reference (`&Settings`) that is immediately dereferenced by the compiler
   --> src/uu/tail/src/tail.rs:248:34
    |
248 |         follow(&mut readers[..], &settings);
    |                                  ^^^^^^^^^ help: change this to: `settings`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

error: could not compile `uu_tail` due to 5 previous errors

@Smicry
Copy link
Contributor Author

Smicry commented Nov 14, 2021

Looks great. Could you please also add high level tests in: https:/uutils/coreutils/blob/master/tests/by-util/test_tail.rs

And make sure that the coverage is great!

ok ~

@Smicry
Copy link
Contributor Author

Smicry commented Nov 14, 2021

fixed #2507

@sylvestre sylvestre merged commit fc851e0 into uutils:master Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants