rust-lang / rust-lang/glob

'*' broken in Pattern::matches_path

Open
#56 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
595
Forks
93
PR merge metrics
No merged PRs in 30d

Description

Here's a recursive file list:

$find src
src/
src/main.rs
src/a/
src/a/b.rs

Running this program

extern crate glob;
use std::path::Path;
use glob::{Pattern,glob};

fn main() {
	let pattern="src/*.rs";

	println!("matches src/a/b.rs: {}",Pattern::new(pattern).unwrap().matches_path(Path::new("src/a/b.rs")));
	
	for entry in glob(pattern).unwrap() {
		println!("globbed: {}", entry.unwrap().display());
	}
}

outputs

matches src/a/b.rs: true
globbed: src/main.rs

Note it DID NOT output globbed: src/a/b.rs. Meaning glob and Pattern::matches_path are inconsistent here. I think glob is correct as '*' should not match across slashes.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Rust reproduction and compare Pattern::matches_path with glob for the pattern src/.rs and nested paths. Trace both matching paths to identify why '' crosses slashes in one case; done means the two APIs agree and the nested src/a/b.rs case is excluded.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.