fmt: clap causes information loss
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
$ cat << EOF > test.txt
> do
> not
> format
> these
> words
> =but
> =these
> =words
> =please
> EOF
$ ../gnu/src/fmt -p= test.txt
do
not
format
these
words
=but these words please
$ cargo run -q fmt -p= test.txt
do not format these words =but =these =words =please
$
Or in general: GNU parses -p=ANYTHING to be the prefix =ANYTHING, whereas clap parses the same argument as the different string ANYTHING. This cannot be easily recovered, and basically requires parsing the arguments from scratch again.
This also affects many other tools. I think it was already documented somewhere, but I couldn't find it.
I see this as yet another strong argument in favor of #4254.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the discrepancy with cargo run -q fmt -p= test.txt and compare it with GNU fmt using the example in the issue. Trace how fmt receives -p=ANYTHING through clap, then identify the affected tools and existing coverage; done means preserving the GNU prefix semantics without losing the leading =.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100