Repository navigation
ptx: single-line error for invalid -S regexp - #14904
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Preserve the original -S pattern in diagnostics to avoid misreporting trailing backslashes.
Review effort: Lite
Findings: 1
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.
|
duplicate of #14740 |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
703c85e to
5c2fde1
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
| USimpleError::new( | ||
| 1, | ||
| translate!("ptx-error-invalid-regexp", "error" => error.to_string()), | ||
| translate!("ptx-error-invalid-regexp", "pattern" => regex.quote()), |
There was a problem hiding this comment.
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>
|
hi, any news on the comment above? thanks |
5c2fde1 to
c945520
Compare
c945520 to
594cbc4
Compare
There was a problem hiding this comment.
🟢 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
|
Sorry for the slow reply, thanks for fixing it! |
e05e313 to
2e3ffbf
Compare
|
GNU testsuite comparison: |
There was a problem hiding this comment.
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
| Regex::new(&escape_trailing_backslash(pattern)).map_err(|_| { | ||
| USimpleError::new( | ||
| 1, | ||
| translate!("ptx-error-invalid-regexp", "pattern" => pattern.quote()), |
| #[rstest] | ||
| #[case::sentence("-S", "ab[c")] | ||
| #[case::word("-W", "(wrong")] | ||
| fn test_invalid_regexp(#[case] option: &str, #[case] pattern: &str) { |
| .stderr_is(format!( | ||
| "ptx: Invalid regular expression (for regexp '{pattern}')\n" | ||
| )); |

An invalid -S regexp made ptx print the regex crate's multi-line parse error.
GNU prints a single line.
which matches GNU (aside from locale quoting). The -S test now checks the stderr line.
Ref: #14705 (ptx/ptx.pl).
Closes #14905