Skip to content

feat: warn when --full-path --glob pattern lacks path anchor (fixes #1650)#1999

Closed
wyf027 wants to merge 3 commits into
sharkdp:masterfrom
wyf027:warn/full-path-glob-anchor-1650
Closed

feat: warn when --full-path --glob pattern lacks path anchor (fixes #1650)#1999
wyf027 wants to merge 3 commits into
sharkdp:masterfrom
wyf027:warn/full-path-glob-anchor-1650

Conversation

@wyf027

@wyf027 wyf027 commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

With --glob and --full-path, patterns match the entire absolute path (from /). Patterns like foo.txt or bar/**/foo.txt often match nothing because they do not anchor to the path root.

This adds a stderr warning when the pattern does not start with / or *, as suggested by @tavianator on #1650.

Does not change matching behavior (orthogonal to #1993).

Test plan

  • cargo test test_warn_when_full_path_glob_missing_leading_anchor
  • cargo clippy -- -D warnings

Fixes #1650

Patterns with -p -g match the whole absolute path; warn if the
pattern does not start with '/' or '*' to help avoid empty results (#1650).

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@wyf027

This comment was marked as low quality.

@wyf027

This comment was marked as low quality.

@wyf027

This comment was marked as low quality.

@tmccombs tmccombs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this should be done in a way that works across operating systems. I'm not sure entirely sure what a robust way to determine if a glob pattern is absolute on windows, largely due to my lack of windows expertise, but I'm confident this isn't adequate.

Also, @leno23 it looks like you may be using an AI agent (perhaps OpenClaw or similar?) that is generating a lot of comments and pull requests, including duplicate pull requests.

Although the use of AI isn't entirely prohibited, we ask that you have a human in the loop reviewing the changes before opening pull requests, and don't automatically add comments. See our contribution policy.

In particular, comments like #1999 (comment) and #1999 (comment) and similar ones on related issues are not useful, and create noise and extra work for maintainers. Similarly with duplicate PRs.

Comment thread src/main.rs Outdated
let Some(first) = opts.pattern.chars().next() else {
return;
};
if first == '/' || first == '*' {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is only correct on unix systems. On windows an absolute path could start with a letter (for example it could start with "c:\").

@wyf027

wyf027 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Closing this since the review made clear that the current approach is not adequate across platforms, and the PR has not had a clear merge path for more than 14 days. Thanks for the review, and sorry for the extra noise from the earlier automated comments.

@wyf027 wyf027 closed this Jun 17, 2026
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.

[BUG] Glob pattern that uses ** does not seem to work

2 participants