Skip to content

ptx: single-line error for invalid -S regexp - #14904

Merged
sylvestre merged 1 commit into
uutils:mainfrom
pizzaburgare:ptx-invalid-sentence-regexp
Nov 5, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
pizzaburgare:ptx-invalid-sentence-regexp

Conversation

@pizzaburgare

@pizzaburgare pizzaburgare commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

An invalid -S regexp made ptx print the regex crate's multi-line parse error.
GNU prints a single line.

$ ptx -S '['
ptx: Invalid regular expression (for regexp '[')

which matches GNU (aside from locale quoting). The -S test now checks the stderr line.

Ref: #14705 (ptx/ptx.pl).

Closes #14905

Copilot AI lite review requested due to automatic review settings September 28, 2026 11:37

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

🟡 Changes recommended

Preserve the original -S pattern in diagnostics to avoid misreporting trailing backslashes.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates ptx -S invalid-regexp diagnostics to produce a concise, GNU-compatible single-line error.

Changes:

  • Simplifies invalid-regexp error formatting.
  • Updates English and French translations.
  • Adds an exact stderr regression test.
File Description
tests/​by-util/​test_ptx.rs Verifies exact stderr output.
src/​uu/​ptx/​src/​ptx.rs Formats invalid-regexp diagnostics.
src/​uu/​ptx/​locales/​fr-FR.ftl Updates French messaging.
src/​uu/​ptx/​locales/​en-US.ftl Updates English messaging.

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

Comment thread src/uu/ptx/src/ptx.rs Resolved
@Devel08

Devel08 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

duplicate of #14740
just in case this gets merged, so that I can close my PR

@xtqqczze

This comment was marked as resolved.

Comment thread src/uu/ptx/src/ptx.rs Resolved
Copilot AI review requested due to automatic review settings September 28, 2026 13:25

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

Preserve the raw regexp in diagnostics and add a regression test for trailing backslashes.

Review effort: Lite
Findings: 1 Medium severity

Open (1)

@xtqqczze

This comment was marked as resolved.

@xtqqczze
xtqqczze removed the request for review from sylvestre September 28, 2026 13:49
@pizzaburgare
pizzaburgare force-pushed the ptx-invalid-sentence-regexp branch from 703c85e to 5c2fde1 Compare September 28, 2026 14:46
@xtqqczze
xtqqczze requested a review from sylvestre September 28, 2026 14:50
@codspeed

codspeed Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 462 skipped benchmarks1


Comparing pizzaburgare:ptx-invalid-sentence-regexp (2e3ffbf) with main (6c880ea)2

Open in CodSpeed

Footnotes

  1. 462 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. ↩

  2. No successful run was found on main (ae1fd53) during the generation of this report, so 6c880ea was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@xtqqczze xtqqczze self-assigned this Sep 28, 2026
Comment thread src/uu/ptx/src/ptx.rs Outdated
USimpleError::new(
1,
translate!("ptx-error-invalid-regexp", "error" => error.to_string()),
translate!("ptx-error-invalid-regexp", "pattern" => regex.quote()),

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.

what about -W? an invalid word regexp is still silently ignored (empty output), could be a follow-up

Should make test ptx/ptx.pl pass

Co-authored-by: pizzaburgare <72048430+pizzaburgare@users.noreply.github.com>
@sylvestre

Copy link
Copy Markdown
Contributor

hi, any news on the comment above? thanks

@sylvestre
sylvestre force-pushed the ptx-invalid-sentence-regexp branch from 5c2fde1 to c945520 Compare November 4, 2026 07:31
Copilot AI lite review requested due to automatic review settings November 4, 2026 07:31
@sylvestre
sylvestre force-pushed the ptx-invalid-sentence-regexp branch from c945520 to 594cbc4 Compare November 4, 2026 07:32

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.

🟢 Approval recommended

No active review issues are reported, and the change includes focused implementation updates with localized diagnostics and parameterized tests covering invalid patterns and command output.

No open issues 🎉

1 resolved since last review

Review effort: Lite

@pizzaburgare

Copy link
Copy Markdown
Contributor Author

Sorry for the slow reply, thanks for fixing it!

Copilot AI lite review requested due to automatic review settings November 4, 2026 08:41
@sylvestre
sylvestre force-pushed the ptx-invalid-sentence-regexp branch from e05e313 to 2e3ffbf Compare November 4, 2026 08:51
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/ptx/ptx is no longer failing!

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

3 open issues

Review effort: Lite

Comment thread src/uu/ptx/src/ptx.rs
Comment on lines +40 to +43
Regex::new(&escape_trailing_backslash(pattern)).map_err(|_| {
USimpleError::new(
1,
translate!("ptx-error-invalid-regexp", "pattern" => pattern.quote()),
Comment thread tests/by-util/test_ptx.rs
Comment on lines +302 to +305
#[rstest]
#[case::sentence("-S", "ab[c")]
#[case::word("-W", "(wrong")]
fn test_invalid_regexp(#[case] option: &str, #[case] pattern: &str) {
Comment thread tests/by-util/test_ptx.rs
Comment on lines +311 to +313
.stderr_is(format!(
"ptx: Invalid regular expression (for regexp '{pattern}')\n"
));
Copilot AI lite review requested due to automatic review settings November 4, 2026 08:58

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.

🟢 Approval recommended

No active review issues are identified, and the changes include focused validation logic with exact diagnostic coverage for invalid patterns.

3 open issues

Review effort: Lite

@sylvestre
sylvestre merged commit 8333be7 into uutils:main Nov 5, 2026
100 checks passed
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.

ptx: should print single-line error for invalid regex

5 participants