Skip to content

ls: add -T support and fix --classify output #7616

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

Merged
merged 13 commits into from
Apr 17, 2025

Conversation

emar-kar
Copy link
Contributor

This update relies on MR46 in uutils-term-grid crate.

This update uses new Filling::Tabs option instead of explicitly setting text separator with \t.

Closes #6897
Closes #7526
Closes #3624

@emar-kar
Copy link
Contributor Author

test_ls_columns was updated with \t since this behavior is on by default

@emar-kar emar-kar marked this pull request as draft March 30, 2025 11:09
@cakebaker cakebaker changed the title add -T support and fix --classify output ls: add -T support and fix --classify output Mar 30, 2025
@emar-kar emar-kar marked this pull request as ready for review April 10, 2025 15:59
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)


at.touch("aaaaaaaa");
at.touch("bbbb");
at.touch("cccc");
at.touch("dddddddd");

ucmd.args(&["-T", "4"])
// Need additional options to simulate columns output.
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain this comment? Is it not supported right now by the options we have in clap?

Copy link
Contributor Author

@emar-kar emar-kar Apr 10, 2025

Choose a reason for hiding this comment

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

If I'm not specifically telling to print out the grid ls output gets piped and returns entries on new lines. Or am I wrong here?

Copy link
Member

@tertsdiepraam tertsdiepraam Apr 10, 2025

Choose a reason for hiding this comment

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

By default yes, but you should be able to force it to column layout with -C, I believe. Some of the tests you've adapted above use that as well.

Copy link
Member

Choose a reason for hiding this comment

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

And could you remove the comment now? It would also be fine to have each of these tests for -C and -x by the way. More tests is (almost) always better!

} else {
Filling::Spaces(2)
let filling = match tab_size {
0 => Filling::Spaces(DEFAULT_SEPARATOR_SIZE),
Copy link
Member

Choose a reason for hiding this comment

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

I guess you left this in as an optimization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, since -T0 literally means no \t I thought it's gonna be a good idea to add this small check here to omit additional work in grid

Copy link
Member

Choose a reason for hiding this comment

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

Could you add that as a comment to the code?

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

@@ -4380,22 +4380,22 @@ fn test_tabsize_formatting() {

scene
.ucmd()
.args(&["-x", "-w18", "-T4"])
.args(&["-C", "-w18", "-T4"])
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should test both -x and -C? The logic is the same in uutils-term-grid I guess, but we shouldn't assume too much about that here.

@emar-kar
Copy link
Contributor Author

Is it something my test change has broken? Or is it something in CI?

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

1 similar comment
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@tertsdiepraam tertsdiepraam merged commit 538355f into uutils:main Apr 17, 2025
70 checks passed
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 --classify not wrapping lines correctly ls: strange --classify output Implement ls -T
2 participants