tr: bad error priority between overlong set2 and offset mismatch upper/lower
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
This is just a minor issue about which error takes precedence.
In particular, the following invocation of tr is invalid for three different reasons:
- The usages of
[:upper:]and[:lower:]are misaligned. - SET2 ends up way too long (expected 256 - 26 = 230, but 256 are provided).
- SET2 has more than one unique character.
It probably doesn't matter too much, but our error-behavior differs from GNU.
$ x230="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$ echo -n 'hello' | tr -c '[:upper:]' "${x230}[:lower:]"
tr: when translating with complemented character classes,
string2 must map all characters in the domain to one
[$? = 1]
$ echo -n 'hello' | cargo run -q tr -c '[:upper:]' "${x230}[:lower:]"
tr: when translating, every 'upper'/'lower' in set2 must be matched by a 'upper'/'lower' in the same position in set1
[$? = 1]
I believe our error message is actually the better one, so feel free to close this as "WONTFIX". Or do we want to exactly match GNU tr even in error message priority? (In some other tools we do!)
(Found while reviewing #6564.)
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
Start by reproducing the two shown tr invocations and comparing their diagnostics with GNU tr. The issue names no source file or test; completion requires deciding the intended error precedence and documenting or testing that behavior before making any change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100