Skip to content

grep: ignore trailing slashes in --exclude-dir - #190

Open
sarankumar1325 wants to merge 2 commits into
uutils:mainfrom
sarankumar1325:grep-exclude-dir-trailing-slash
Open

sarankumar1325 wants to merge 2 commits into
uutils:mainfrom
sarankumar1325:grep-exclude-dir-trailing-slash

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Summary

--exclude-dir=vendor/ (and vendor//) previously matched nothing, because the pattern was compared to the directory's bare name. Trailing slashes are now stripped, matching GNU grep.

Fixes #166

Test plan

  • cargo test --test test_grep exclude_dir_ignores_trailing_slashes (fails on main)
  • cargo test --test test_grep recursive_with_include_exclude
  • cargo fmt --check
  • cargo clippy --all-targets -- -D warnings

AI assistance: used to draft the patch; I reviewed and verified it against GNU grep 3.11 and the failing test on main.

GNU grep 2.19+ treats --exclude-dir=NAME/ the same as --exclude-dir=NAME,
because the match is against the directory's bare name. Strip trailing
slashes before compiling the exclude-dir glob.

Fixes uutils#166

Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 9, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codspeed

codspeed Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 3 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 10 untouched benchmarks
⏩ 17 skipped benchmarks1


Comparing sarankumar1325:grep-exclude-dir-trailing-slash (5de18a0) with main (322d1db)

Open in CodSpeed

Footnotes

  1. 17 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment thread tests/test_grep.rs Outdated
}

#[test]
fn exclude_dir_ignores_trailing_slashes() {

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.

could be added to recursive_with_include_exclude instead of a new fn, no?

Copilot AI balanced review requested due to automatic review settings November 9, 2026 21:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

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.

grep - --exclude-dir=NAME/ with a trailing slash excludes nothing

3 participants