-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
tac: add regex flavor translation for compatibility and new test case #10416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
tests/by-util/test_tac.rs
Outdated
| .args(&["-r", "-s", r"[^x]\|x"]) | ||
| .pipe_in("abc") | ||
| .succeeds() | ||
| .stdout_contains("cba"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .stdout_contains("cba"); | |
| .stdout_is("cba"); |
src/uu/tac/src/tac.rs
Outdated
|
|
||
| // Make the regex flavor compatible with `regex` crate | ||
| fn translate_regex_flavor(regex: &str) -> String { | ||
| let result: String = regex.replace("\\|", "|"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you only handles \| but BRE has other differences (\(, \), \{, \} for grouping/repetition).
maybe do that now (and add tests)
also unnecessary explicit type annotation
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Adresses #10320
Added a function to make any necessary translations to input regex in order to make them
regexcompatible.Done to translate
\|into|for now, but should be easy to add any other cases that come up in the future.