Skip to content
Myr

--glob: '*' does not match on path separators

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by David Peter · parent 2bab4a2 · Browse files · 3 files+23 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+23 added−3 removed

  • tests:+10 added−0 removed
  • other:+13 added−3 removed

3 files+23 added−3 removed

modified:src/main.rs+9 added-3 removed
16 unmodified lines
17use std::time;1819use anyhow::{anyhow, Context, Result};20use atty::Stream;21use globset::Glob;21use globset::GlobBuilder;22use lscolors::LsColors;23use regex::bytes::{RegexBuilder, RegexSetBuilder};2425use crate::exec::CommandTemplate;
96 unmodified lines
122 ));123 }124125 let pattern_regex = if matches.is_present("glob") {126 let glob = Glob::new(pattern)?;126 let glob = GlobBuilder::new(pattern).literal_separator(true).build()?;127 glob.regex().to_owned()128 } else if matches.is_present("fixed-strings") {129 // Treat pattern as literal string if '--fixed-strings' is used130 regex::escape(pattern)
164 unmodified lines
295 max_results: matches296 .value_of("max-results")297 .and_then(|n| usize::from_str_radix(n, 10).ok())298 .filter(|&n| n != 0)299 .or_else(|| if matches.is_present("max-one-result") { Some(1) } else { None }),299 .or_else(|| {300 if matches.is_present("max-one-result") {301 Some(1)302 } else {303 None304 }305 }),306 };307308 let re = RegexBuilder::new(&pattern_regex)309 .case_insensitive(!config.case_sensitive)
26 unmodified lines
modified:tests/tests.rs+10 added
270 unmodified lines
271 "one/b.foo272 one/two/c.foo273 one/two/three/d.foo",274 );275276 te.assert_output(277 &["--glob", "--full-path", "**/one/*/*.foo"],278 " one/two/c.foo",279 );280281 te.assert_output(282 &["--glob", "--full-path", "**/one/*/*/*.foo"],283 " one/two/three/d.foo",284 );285}286287#[test]288fn test_smart_case_glob_searches() {
1238 unmodified lines
modified:CHANGELOG.md+4 added
19 unmodified lines
20- `LS_COLORS` entries with unsupported font styles are not completely ignored, see #5522122## Changes2324- When using `--glob` in combination with `--full-path`, a `*` character does not match a path25 separation character (`/` or `\\`) anymore. You can use `**` for that. This allows things like26 `fd -p -g '/some/base/path/*/*/*.txt'` which would previously match to arbitrary depths (instead27 of exactly two folders below `/some/base/path`. See #404.282930## Other31
401 unmodified lines