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

df: implement the --output command-line argument #3176

Merged
merged 3 commits into from
Mar 11, 2022

Conversation

jfinkels
Copy link
Collaborator

This pull request implements the --output command-line argument, which allows specifying an exact sequence of columns to display in the output table. For example,

$ df --output=source,fstype | head -n3
Filesystem       Type
udev             devtmpfs
tmpfs            tmpfs

(The spacing does not exactly match the spacing of GNU df yet.)

In order to do this, we replace the Options.show_fs_type and Options.show_inode_instead fields with the more general Options.columns, a Vec of Column variants representing the exact sequence of columns to display in the output. This makes Options able to represent arbitrary output column display configurations.

Fixes #3057.

@jfinkels jfinkels force-pushed the df-output-columns-2 branch from de0cb85 to 20365c0 Compare February 22, 2022 03:33
@jfinkels
Copy link
Collaborator Author

The GNU tests show

Error: GNU test failed: tests/ls/readdir-mountpoint-inode. tests/ls/readdir-mountpoint-inode is passing on 'main'. Maybe you have to rebase?

My hunch is that test was previously passing by accident, since the test script starts with

df --local --out=target

which, before this pull request, would have returned rows with all the default columns instead of rows with just the target column. In other words, although this test is causing a new error in the GNU test suite, it is actually revealing a deficiency in our implementation of ls that should have been caught previously but wasn't. (That's just a guess, I haven't verified that!)

@jfinkels jfinkels force-pushed the df-output-columns-2 branch 2 times, most recently from 4443950 to f303426 Compare February 27, 2022 17:22
@jfinkels jfinkels force-pushed the df-output-columns-2 branch 3 times, most recently from aec467d to c2a77ec Compare March 8, 2022 03:10
@sylvestre sylvestre force-pushed the df-output-columns-2 branch from c2a77ec to 477a66f Compare March 9, 2022 18:47
@sylvestre
Copy link
Contributor

Seems related but a GNU test is failing:
Error: GNU test failed: tests/ls/readdir-mountpoint-inode. tests/ls/readdir-mountpoint-inode is passing on 'main'. Maybe you have to rebase?

@jfinkels
Copy link
Collaborator Author

Yes, that is expected. Please see my comment above: #3176 (comment)

Replace the `Options.show_fs_type` and `Options.show_inode_instead`
fields with the more general `Options.columns`, a `Vec` of `Column`
variants representing the exact sequence of columns to display in the
output. This makes `Options` able to represent arbitrary output column
display configurations.
Implement the `--output` command-line argument, which allows
specifying an exact sequence of columns to display in the output
table. For example,

    $ df --output=source,fstype | head -n3
    Filesystem       Type
    udev             devtmpfs
    tmpfs            tmpfs

(The spacing does not exactly match the spacing of GNU `df` yet.)

Fixes uutils#3057.
@jfinkels jfinkels force-pushed the df-output-columns-2 branch from 477a66f to c0cd017 Compare March 11, 2022 03:51
@sylvestre
Copy link
Contributor

sorry, I don't know how i missed your comment :(

@sylvestre sylvestre merged commit 1795272 into uutils:main Mar 11, 2022
@jfinkels jfinkels deleted the df-output-columns-2 branch March 12, 2022 18:36
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.

df: doesn't respect --output argument
2 participants