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

ls: fix issue #6697 (different "ls -lF --dired" from GNU) #6699

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kkkykin
Copy link

@kkkykin kkkykin commented Sep 16, 2024

Please let me know if there are any wrong. I'm not familiar with Rust.
Fix #6697

@cakebaker
Copy link
Contributor

Can you please run cargo fmt?

@sylvestre
Copy link
Contributor

could you please add a test to make sure we don't regress ?
https://github.com/uutils/coreutils/blob/main/tests/by-util/test_ls.rs

@kkkykin
Copy link
Author

kkkykin commented Sep 16, 2024

Yes, added. Is this ok?

@sylvestre
Copy link
Contributor

yes, sorry, i missed your comment :)

Comment on lines 85 to 86
let end = start + dfl_len;
let end_filename = start + dfn_len;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for a different pr but we should rename dfl & dfn for something more explicit

src/uu/ls/src/dired.rs Outdated Show resolved Hide resolved
@@ -195,29 +207,60 @@ mod tests {
fn test_calculate_dired() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a new tests which shows when end and end_filename are different ?

@@ -42,7 +42,9 @@ use uucore::error::UResult;
#[derive(Debug, Clone, PartialEq)]
pub struct BytePosition {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not a big deal because --dired isn't used a lot but we are storing extra data every time even this case happens rarely

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this solution might be a bit silly, but I'm not good at programming.

It seems like 'end_line' is only used to calculate the offset for the next line, so it should be fine to just store 'end_filename' maybe.

I'll try to optimize it. :)

@kkkykin
Copy link
Author

kkkykin commented Oct 7, 2024

And apologies for my messy coding style; it might be difficult to review. 😢

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.

ls: Behaviour differs from GNU Coreutils with "--dired"/"-D"
3 participants