coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Allow repeated flags much more often

Open BenWiederhake opened this issue 1 year ago • 8 comments

If seems that there are many cases where we define self-conflicts, but GNU accepts repeated arguments. This is especially unnecessary for boolean flags. Let's fix that! This issue tracks progress for all utils.

  • [ ] chgrp: at least -v is broken
  • [ ] chmod: not considered yet
  • [ ] chown: not considered yet
  • [ ] chroot: not considered yet
  • [ ] comm: at least -1 is broken
  • [ ] cp: at least -a is handled correctly
  • [ ] csplit: at least -k is broken
  • [ ] date: at least --resolution is broken: #6143 , rest is fixed by #6142
  • [ ] du: at least -s is broken
  • [ ] echo: at least -n is broken
  • [ ] fmt: at least -c is broken, fixed by #6355
  • [ ] fold: at least -b is broken
  • [ ] id: at least -u is broken
  • [ ] install: at least -b is broken
  • [ ] join: at least -z is broken
  • [ ] kill: at least -l is broken
  • [ ] ln: not considered yet
  • [ ] logname: not considered yet
  • [ ] ls: not considered yet
  • [ ] mkdir: not considered yet
  • [ ] mkfifo: not considered yet
  • [ ] mknod: not considered yet
  • [ ] mktemp: not considered yet
  • [ ] more: not considered yet
  • [ ] mv: not considered yet
  • [ ] nice: not considered yet
  • [ ] nl: not considered yet
  • [ ] nohup: not considered yet
  • [ ] nproc: not considered yet
  • [ ] numfmt: not considered yet
  • [ ] od: not considered yet
  • [ ] paste: not considered yet
  • [ ] pathchk: not considered yet
  • [ ] pinky: not considered yet
  • [ ] pr: not considered yet
  • [ ] printenv: not considered yet
  • [ ] printf: not considered yet
  • [ ] ptx: not considered yet
  • [ ] pwd: not considered yet
  • [ ] readlink: not considered yet
  • [ ] realpath: not considered yet
  • [ ] rm: not considered yet
  • [ ] rmdir: not considered yet
  • [ ] runcon: not considered yet
  • [ ] seq: not considered yet
  • [ ] shred: not considered yet
  • [ ] sleep: not considered yet
  • [ ] sort: at least --sort=month --sort=numeric is broken
  • [ ] split: not considered yet
  • [ ] stat: not considered yet
  • [ ] stdbuf: not considered yet
  • [ ] stty: not considered yet
  • [ ] sum: not considered yet
  • [ ] sync: not considered yet
  • [ ] tac: not considered yet
  • [ ] tail: not considered yet
  • [ ] tee: not considered yet
  • [ ] test: not considered yet
  • [ ] timeout: not considered yet
  • [ ] touch: not considered yet
  • [ ] truncate: not considered yet
  • [ ] tsort: not considered yet
  • [ ] tty: not considered yet
  • [ ] uname: not considered yet
  • [ ] unexpand: not considered yet
  • [ ] uniq: not considered yet
  • [ ] unlink: not considered yet
  • [ ] uptime: not considered yet
  • [ ] users: not considered yet
  • [ ] vdir: not considered yet
  • [ ] wc: not considered yet
  • [ ] who: not considered yet
Not a problem (solved / not affected / works already)
  • [X] arch: no repeatable options
  • [X] base32: fully handled, see #6007
  • [X] base64: fully handled, see #6007
  • [X] basename: fully handled, see #6018
  • [X] basenc: fully handled, see #6007
  • [X] cat: at least -u is broken, see #6034
  • [X] chcon: at least -v is broken, see #6039
  • [X] cksum: at least --base64 is broken, see #6041
  • [X] cut: works already
  • [X] dd: Seems to already work, not gonna touch it.
  • [X] df: works already
  • [X] dir: just defers to ls
  • [X] dircolors: at least -p is broken, see #6150
  • [X] dirname: at least -z is broken, see #6151
  • [X] env: at least -i is broken, fixed by #6288
  • [X] expand: works already
  • [X] expr: works completely differently
  • [X] factor: already works
  • [X] false: has no flags/args
  • [X] groups: has no flags/args
  • [X] hashsum: not a GNU tool
  • [X] head: works already
  • [X] hostid: has no flags/args
  • [X] hostname: works, BUT INCOMPLETE AND FRAGILE
  • [X] link: has no flags/args
  • [X] shuf: fully handled, see #5978 and #5989
  • [X] tr: fully handled, see #6006
  • [X] true: has no flags/args
  • [X] whoami: no repeatable options
  • [X] yes: no repeatable options

BenWiederhake avatar Feb 23 '24 00:02 BenWiederhake

If I recall correctly, we fixed all of this with the args_override_self function in clap. What leads you to believe that this is broken?

tertsdiepraam avatar Feb 23 '24 06:02 tertsdiepraam

  • Only 11 tools use args_override_self, and gut feeling says that more than 11 tools have self-overriding flags
  • shuf used to use args_override_self and it was wrong
  • tr didn't have it yet
  • 2 out of 2 is a large enough rate to warrant making an issue out of it ^^

I didn't look much further into it yet. Now that I try out random other tools, it seems like you're right :D I'll close this issue when I've checked all the tools.

EDIT: Oh! sort also doesn't work because it uses args_override_self:

$ ls | sort --sort=month --sort=numeric
sort: options '-Mn' are incompatible
[$? = 2]
$ ls | cargo run sort --sort=month --sort=numeric
CODE_OF_CONDUCT.md
COMMANDS.txt
…

BenWiederhake avatar Feb 23 '24 10:02 BenWiederhake

Nice find :)

tertsdiepraam avatar Feb 23 '24 11:02 tertsdiepraam

Ah, apparently I prevented auto-closing in the wrong way. Can someone re-open this issue? It'll be a long time until this issue can be closed.

BenWiederhake avatar Feb 25 '24 10:02 BenWiederhake

I don't think an issue like this is the right approach. The problems should be fixed, but we should open issues for the problems we find, not for the potential problems we might find if that makes sense. An issue like this tends to go stale, becomes out of date, etc.

tertsdiepraam avatar Feb 25 '24 11:02 tertsdiepraam

In principle I would usually agree with this argument, but given that 11 out of 12 tools that I looked at have at least one bug related to it, I'll continue using the above checklist.

Hmm. Actually, I think that answers it: Let's just keep this issue closed, because I can use the checklist anyway.

BenWiederhake avatar Feb 25 '24 11:02 BenWiederhake

Yes, but usually different bugs right? I'd keep this open if the exact same issue was present in all utils. But yeah, feel free to keep using the checklist :)

tertsdiepraam avatar Feb 25 '24 11:02 tertsdiepraam

Maybe we should reopen this. I got confused with other functionality and you're right that this should be checked for more utils.

tertsdiepraam avatar Mar 24 '24 18:03 tertsdiepraam