GithubHelp home page GithubHelp logo

Comments (3)

tavianator avatar tavianator commented on June 5, 2024 2

So if --absolute-path is specified, we eagerly normalize the command line search paths:

fd/src/cli.rs

Lines 666 to 672 in 4efc05e

fn normalize_path(&self, path: &Path) -> PathBuf {
if self.absolute_path {
filesystem::absolute_path(path.normalize().unwrap().as_path()).unwrap()
} else {
path.to_path_buf()
}
}

Without --absolute-path, the search path stays as-is (..). Then later when matching, if --full-path is given, we call path_absolute_form():

fd/src/walk.rs

Lines 513 to 516 in b874462

let search_str: Cow<OsStr> = if config.search_full_path {
let path_abs_buf = filesystem::path_absolute_form(entry_path)
.expect("Retrieving absolute path succeeds");
Cow::Owned(path_abs_buf.as_os_str().to_os_string())

But path_absolute_form() doesn't normalize:

fd/src/filesystem.rs

Lines 14 to 21 in b874462

pub fn path_absolute_form(path: &Path) -> io::Result<PathBuf> {
if path.is_absolute() {
return Ok(path.to_path_buf());
}
let path = path.strip_prefix(".").unwrap_or(path);
env::current_dir().map(|path_buf| path_buf.join(path))
}

I think having --absolute-path change the result set is a bug we need to fix. But we need to be careful.

from fd.

tmccombs avatar tmccombs commented on June 5, 2024

Hmm i suspect the path it is comparing to might be

/tmp/1/2/../foo

from fd.

tavianator avatar tavianator commented on June 5, 2024

@tmccombs That's my guess too. But trying to confirm with --absolute-path causes it to not match any more! I guess that's another bug.

from fd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.