Skip to content

tr: document what a SET may hold in the help - #14792

Open
Ascol57 wants to merge 2 commits into
uutils:mainfrom
Ascol57:tr-document-sets-in-help
Open

Ascol57 wants to merge 2 commits into
uutils:mainfrom
Ascol57:tr-document-sets-in-help

Conversation

@Ascol57

@Ascol57 Ascol57 commented Sep 21, 2026

Copy link
Copy Markdown

Fixes #14688

tr --help, and so the generated man page, listed the options and stopped
there. The synopsis mentions [sets] and nothing said what a SET may hold, so
there was no way to learn about ranges, repeats, escapes or character classes
from the page. It came to 18 lines against GNU's 54.

The reporter hit this after upgrading to Ubuntu 26.04, which ships uutils.

What is documented

The text is written from what src/uu/tr/src/operation.rs actually parses,
not translated from GNU's wording, since the licenses are not compatible.
Every claim was checked against the binary and against GNU 9.7:

  • the escapes \NNN (one to three octal digits), \\, \a, \b, \f,
    \n, \r, \t, \v
  • ranges CHAR1-CHAR2
  • [CHAR*] and [CHAR*REPEAT], with REPEAT read as octal when it starts
    with 0
  • equivalence classes [=CHAR=]
  • all twelve character classes the parser accepts, each described from the
    byte set it expands to — [:graph:] excludes the space and [:print:]
    includes it, [:blank:] is tab and space while [:space:] adds the
    vertical whitespace
  • when translation happens, how SET2 is padded with its last character and
    how --truncate-set1 shortens SET1 instead, that only [:lower:] and
    [:upper:] may appear in SET2, and that squeezing applies to the last SET
    after any translation or deletion

The sets operand also gets a help string, so it no longer shows as a bare
[sets]... with an empty description.

French

fr-FR.ftl was at full parity with en-US.ftl before this change, so it is
translated too rather than left to fall back to English.

Checks

  • moz-fluent-lint --config .github/fluent_linter_config.yml src/uu/tr/locales/
    reports no errors on both files.
  • The generated man page renders cleanly: uudoc manpage tr | groff -man -ww
    emits no warnings, and the escapes come out as \NNN, \\, \a rather
    than doubled. Entries were kept short enough not to wrap, matching how the
    stat after-help block renders.
  • The new test asserts the help documents the ranges, repeats, equivalence
    classes, escapes, every one of the twelve class names, and the operand
    description. Restoring the old one-line after-help makes it fail with
    the help does not document CHAR1-CHAR2.
  • 162 tr tests pass, 169 with feat_diagnostics. clippy and cargo fmt
    clean.

Copilot AI lite review requested due to automatic review settings September 21, 2026 18:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Low severity

Open (2)
What changed in this PR

Documents the syntax and behavior of tr SET operands in help output and adds coverage to ensure the generated help remains informative.

Changes:

  • Adds comprehensive English and French documentation for escapes, ranges, repeats, equivalence classes, character classes, and translation behavior.
  • Adds a localized help description for the sets operand.
  • Adds a regression test covering the documented SET syntax and operand description.
File Description
tests/​by-util/​test_tr.rs Verifies that help output documents SET syntax and all supported character classes.
src/​uu/​tr/​src/​tr.rs Associates the localized SET description with the positional operand.
src/​uu/​tr/​locales/​fr-FR.ftl Adds the French SET syntax and behavior documentation.
src/​uu/​tr/​locales/​en-US.ftl Adds the English SET syntax and behavior documentation.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/uu/tr/locales/fr-FR.ftl Outdated
Comment thread src/uu/tr/locales/fr-FR.ftl Outdated
Ascol57 added a commit to Ascol57/coreutils that referenced this pull request Sep 21, 2026
The [CHAR*REPEAT] entry had no subject for 'commence'. The space
descriptions used feminine agreement, while the 106 French locale files of
the repository consistently treat 'espace' as masculine.

Reported by review on uutils#14792.
Copilot AI review requested due to automatic review settings September 21, 2026 19:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Low severity

Open (2)

@codspeed

codspeed Bot commented Sep 22, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 6.15%

❌ 1 regressed benchmark
✅ 7 untouched benchmarks
⏩ 424 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory tr_ascii_range_lower_to_upper 124.7 KB 132.9 KB -6.15%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Ascol57:tr-document-sets-in-help (f060119) with main (406e5a8)

Open in CodSpeed

Footnotes

  1. 424 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

The help listed the options and stopped there, so neither it nor the man
page generated from it said anything about the ranges, repeats, escapes,
equivalence classes and character classes that a SET accepts, nor what
the [sets] operand is.

Describe them from what the sequence parser implements, give the sets
operand a help string, and keep the French translation at parity.

Fixes uutils#14688
The [CHAR*REPEAT] entry had no subject for 'commence'. The space
descriptions used feminine agreement, while the 106 French locale files of
the repository consistently treat 'espace' as masculine.

Reported by review on uutils#14792.
Copilot AI review requested due to automatic review settings September 22, 2026 05:42
@sylvestre
sylvestre force-pushed the tr-document-sets-in-help branch from 58fab84 to f060119 Compare September 22, 2026 05:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Address the incomplete escape and equivalence-class documentation, and pin LC_ALL in the locale-sensitive test.

Review effort: Lite
Findings: None

Resolved since last review (2)

@Ascol57

Ascol57 commented Sep 22, 2026

Copy link
Copy Markdown
Author

I work on it when I come back from school.

@sylvestre

Copy link
Copy Markdown
Contributor

clippy is sad on 5 jobs :)

error: empty line after outer attribute
    --> tests/by-util/test_tr.rs:1655:1
     |
1655 | / #[cfg(all(feature = "feat_diagnostics", not(wasi_runner)))]
1656 | |
     | |_^
1657 |   mod diagnostics {
     |   --------------- the attribute applies to this module
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#empty_line_after_outer_attr
     = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_outer_attr)]`
     = help: if the empty line is unintentional, remove it

This branch has not been deployed

No deployments
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.

Missing information in the man page for tr

3 participants