feat: warn when --full-path --glob pattern lacks path anchor (fixes #1650)#1999
feat: warn when --full-path --glob pattern lacks path anchor (fixes #1650)#1999leno23 wants to merge 2 commits into
Conversation
Patterns with -p -g match the whole absolute path; warn if the pattern does not start with '/' or '*' to help avoid empty results (sharkdp#1650). Co-authored-by: Cursor <cursoragent@cursor.com>
…1997 Co-authored-by: Cursor <cursoragent@cursor.com>
This comment was marked as low quality.
This comment was marked as low quality.
This comment was marked as low quality.
This comment was marked as low quality.
The warning test belongs to sharkdp#1650 / sharkdp#1999, not the multi search-path exclude fix. Co-authored-by: Cursor <cursoragent@cursor.com>
This comment was marked as low quality.
This comment was marked as low quality.
tmccombs
left a comment
There was a problem hiding this comment.
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.
| let Some(first) = opts.pattern.chars().next() else { | ||
| return; | ||
| }; | ||
| if first == '/' || first == '*' { |
There was a problem hiding this comment.
This is only correct on unix systems. On windows an absolute path could start with a letter (for example it could start with "c:\").
Summary
With
--globand--full-path, patterns match the entire absolute path (from/). Patterns likefoo.txtorbar/**/foo.txtoften 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_anchorcargo clippy -- -D warningsFixes #1650
Made with Cursor