8000 df: -h -H shouldn't cause an error · Issue #3366 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

df: -h -H shouldn't cause an error #3366

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

Closed
cakebaker opened this issue Apr 4, 2022 · 3 comments · Fixed by #3414
Closed

df: -h -H shouldn't cause an error #3366

cakebaker opened this issue Apr 4, 2022 · 3 comments · Fixed by #3414
Labels

Comments

@cakebaker
Copy link
Contributor

When running df -h -H, the two options are treated as mutually exclusive and clap generates an error. This is the behavior I expected. However, GNU df handles this situation differently and doesn't generate an error. It simply ignores the first option.

$ ./target/debug/coreutils df -h -H
error: The argument '--human-readable' cannot be used with '--si'

USAGE:
    ./target/debug/coreutils df [OPTION]... [FILE]...

For more information try --help
$ df -h -H
Filesystem      Size  Used Avail Use% Mounted on
dev             4.2G     0  4.2G   0% /dev
run             4.2G  1.4M  4.2G   1% /run
/dev/sda8       470G  123G  323G  28% /
tmpfs           4.2G   57M  4.1G   2% /dev/shm
tmpfs           4.2G  4.5M  4.2G   1% /tmp
/dev/sda2       269M   86M  183M  33% /boot
tmpfs           823M   78k  823M   1% /run/user/1000

$ df -H
Filesystem      Size  Used Avail Use% Mounted on
dev             4.2G     0  4.2G   0% /dev
run             4.2G  1.4M  4.2G   1% /run
/dev/sda8       470G  123G  323G  28% /
tmpfs           4.2G   57M  4.1G   2% /dev/shm
tmpfs           4.2G  4.5M  4.2G   1% /tmp
/dev/sda2       269M   86M  183M  33% /boot
tmpfs           823M   78k  823M   1% /run/user/1000

$ df -H -h
Filesystem      Size  Used Avail Use% Mounted on
dev             3.9G     0  3.9G   0% /dev
run             3.9G  1.4M  3.9G   1% /run
/dev/sda8       437G  114G  301G  28% /
tmpfs           3.9G   54M  3.8G   2% /dev/shm
tmpfs           3.9G  4.3M  3.9G   1% /tmp
/dev/sda2       256M   82M  175M  33% /boot
tmpfs           785M   76K  785M   1% /run/user/1000

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             3.9G     0  3.9G   0% /dev
run             3.9G  1.4M  3.9G   1% /run
/dev/sda8       437G  114G  301G  28% /
tmpfs           3.9G   54M  3.8G   2% /dev/shm
tmpfs           3.9G  4.3M  3.9G   1% /tmp
/dev/sda2       256M   82M  175M  33% /boot
tmpfs           785M   76K  785M   1% /run/user/1000
@sylvestre
Copy link
Contributor

Maybe, it could be interesting to report an issue on the GNU bug tracker

@tertsdiepraam
Copy link
Member

I think this is intentional on GNU's part. They use overriding options all over this place. I think the reasoning is that one can define an alias dh = df -h but then still use dh -H. In clap this can be modelled with Arg::overrides_with.

@jfinkels
Copy link
Collaborator
jfinkels commented Apr 9, 2022

Yes it is a feature of the argument parser that they use: you can supply any number of arguments and only the last one gets used:

$ df -hHhHhHHHHHhhHH | head -n2
Filesystem                 Size  Used Avail Use% Mounted on
udev                       4.0G     0  4.0G   0% /dev

@tertsdiepraam tertsdiepraam linked a pull request Apr 17, 2022 that will close this issue
sylvestre added a commit that referenced this issue Apr 18, 2022
df: -h -H shouldn't cause an error #3366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0