Skip to content

expr: switch to leftmost-longest regex matching behavior - #14527

Merged
sylvestre merged 2 commits into
uutils:mainfrom
forkeith:expr_leftmost_longest
Sep 13, 2026
Merged

expr: switch to leftmost-longest regex matching behavior#14527
sylvestre merged 2 commits into
uutils:mainfrom
forkeith:expr_leftmost_longest

Conversation

@keith-hall

Copy link
Copy Markdown
Contributor

Fixes a bug in expr whereby it was using leftmost-first match semantics instead of leftmost-longest as required by POSIX

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 unresolved review issues remain, and all reviewed changes are covered.

Pull request overview

Updates expr to use POSIX leftmost-longest regex matching.

Changes:

  • Enables fancy-regex leftmost-longest matching.
  • Adds an alternation regression test.
  • Updates dependency metadata and lockfile.
File summaries
File Description
src/uu/expr/src/syntax_tree.rs Configures matching behavior and adds a regression test.
Cargo.toml Updates and configures fancy-regex.
Cargo.lock Records dependency metadata changes.
Review details
  • Files reviewed: 2/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@oech3

This comment was marked as resolved.

@keith-hall
keith-hall force-pushed the expr_leftmost_longest branch from cc75d7c to 2a2a061 Compare September 13, 2026 05:55
Copilot AI review requested due to automatic review settings September 13, 2026 05:55
@keith-hall

Copy link
Copy Markdown
Contributor Author

Thankyou for adding unit test. But we prefer testing by actual expr binary at https://github.com/uutils/coreutils/blob/main/tests/by-util/test_expr.rs .

thanks, added a test here too

@keith-hall keith-hall changed the title switch expr to leftmost longest regex matching behavior expr: switch to leftmost-longest regex matching behavior Sep 13, 2026

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 unresolved review issues were identified.

Review details
  • Files reviewed: 3/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@sylvestre

Copy link
Copy Markdown
Contributor

please also update Cargo.lock in fuzz/

Copilot AI review requested due to automatic review settings September 13, 2026 08:19
@keith-hall

Copy link
Copy Markdown
Contributor Author

please also update Cargo.lock in fuzz/

done, thanks

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 unresolved issues were identified.

Review details
  • Files reviewed: 3/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/symlink (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/cut/bounded-memory is now being skipped but was previously passing.

@sylvestre
sylvestre merged commit bde7873 into uutils:main Sep 13, 2026
158 of 221 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

cool stuff, thanks

@oech3

oech3 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

@keith-hall Should we use .seek(true) at expr too?

@keith-hall

Copy link
Copy Markdown
Contributor Author

I would suggest to benchmark it and decide - if a match would be found at the beginning of the haystack, seeking might add unnecessary extra overhead... If the pattern is unanchored and the haystack is large, then likely it would make sense to seek.

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.

4 participants