Skip to content

expr: Fix parsing regex anchors '^' and '$' #7953

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

Merged
merged 2 commits into from
May 23, 2025

Conversation

frendsick
Copy link
Contributor

This PR handles and tests the cases where '^' or '$' should be interpreted as special characters.

^ acts as a special character only at the beginning of the regular expression or subexpression (that is, after ( or |).

It ($) is the same as ^, but refers to end of pattern space. $ also acts as a special character only at the end of the regular expression or subexpression (that is, before ) or |)

Reference: https://www.gnu.org/software/sed/manual/html_node/BRE-syntax.html

fixes #7951, fixes #7952

@frendsick
Copy link
Contributor Author

The Style/lint tests are failing, but they seem unrelated to expr and thus unrelated to this PR. How should I handle those, or do we leave them as is for now?

@frendsick
Copy link
Contributor Author

The clippy errors are already reported by #7945

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@sylvestre sylvestre force-pushed the fix/expr-regex-anchors branch from c44d228 to 3f9a5f3 Compare May 19, 2025 09:17
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

@frendsick frendsick requested a review from RenjiSann May 22, 2025 06:22
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/install/install-C-selinux is no longer failing!

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@RenjiSann
Copy link
Collaborator

Thanks ! The changes look good to me 👍

Lastly, can you squash your commits in only 2-3 ? I can squash them all in 1 and merge, but I find it interesting to have 1 commit for ^, one for $ and one for the added tests

@frendsick frendsick force-pushed the fix/expr-regex-anchors branch from 5d88d56 to 2933286 Compare May 23, 2025 12:32
@frendsick
Copy link
Contributor Author

@RenjiSann, please check now.

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@RenjiSann RenjiSann merged commit cd9ce77 into uutils:main May 23, 2025
73 checks passed
@RenjiSann
Copy link
Collaborator

Thank you for your contribution ! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants