Skip to content

Conversation

@CrazyRoka
Copy link
Contributor

Description

This PR fixes a panic in ptx when an invalid regular expression is passed to the -W (--word-regexp) argument.

Previously, running:
ptx -W 'bar\\\'
would result in a Rust panic (called Result::unwrap() on an Err value).

This change catches the regex::Error, wraps it in a USimpleError, and ensures the program exits with code 1 and prints a user-friendly message to stderr.

Testing

  • Added unit tests in tests/by-util/test_ptx.rs to verify:
    • Trailing backslashes (bar\) return exit code 1.
    • Unclosed groups ((wrong) return exit code 1.
    • The stderr contains "invalid regular expression".

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/sort/sort-debug-keys is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/sort/sort-debug-keys is no longer failing!

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.

2 participants