Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 62 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ ignore = "0.4.25"
regex = "1.12.2"
regex-syntax = "0.8"
ctrlc = "3.5"
globset = "0.4"
globset = "0.4.18"
anyhow = "1.0"
etcetera = "0.11"
normpath = "1.5.1"
crossbeam-channel = "0.5.15"
clap_complete = {version = "4.6.5", optional = true}
faccess = "0.2.4"
jiff = "0.2.27"
memchr = "2.8.0"
pcre2 = {version = "0.2.11", optional = true}

[dependencies.clap]
version = "4.6.1"
Expand Down Expand Up @@ -95,6 +97,7 @@ codegen-units = 1
use-jemalloc = ["tikv-jemallocator"]
completions = ["clap_complete"]
base = ["use-jemalloc"]
pcre = ["dep:pcre2"]
default = ["use-jemalloc", "completions"]

[package.metadata.binstall]
Expand Down
16 changes: 13 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ pub struct Opts {
)]
pub regex: bool,

/// Use the PCRE regex engine
///
/// This allows you to use features like backreferences and lookarounds.
#[cfg(feature = "pcre")]
#[arg(
long,
overrides_with_all(["glob", "regex"]),
conflicts_with("fixed_strings"),
long_help
)]
pub pcre: bool,

/// Treat the pattern as a literal string instead of a regular expression. Note
/// that this also performs substring comparison. If you want to match on an
/// exact filename, consider using '--glob' or '--exact' instead.
Expand Down Expand Up @@ -629,13 +641,11 @@ pub struct Opts {
/// is considered a match. If your pattern starts with a dash (-), make sure to
/// pass '--' first, or it will be considered as a flag (fd -- '-foo').
#[arg(
default_value = "",
hide_default_value = true,
value_name = "pattern",
help = "the search pattern (a regular expression, unless '--glob' is used; optional)",
long_help
)]
pub pattern: String,
pub pattern: Option<String>,

/// Set the path separator to use when printing file paths. The default is
/// the OS-specific separator ('/' on Unix, '\' on Windows).
Expand Down
3 changes: 0 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ use crate::fmt::FormatTemplate;

/// Configuration options for *fd*.
pub struct Config {
/// Whether the search is case-sensitive or case-insensitive.
pub case_sensitive: bool,

/// Cached current working directory for absolute path construction.
/// Populated when `--full-path` is set; `None` means search by filename only.
pub full_path_base: Option<PathBuf>,
Expand Down
18 changes: 0 additions & 18 deletions src/filesystem.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::borrow::Cow;
use std::env;
use std::ffi::OsStr;
use std::fs;
use std::io;
#[cfg(any(unix, target_os = "redox"))]
Expand Down Expand Up @@ -99,22 +97,6 @@ pub fn is_pipe(_: fs::FileType) -> bool {
false
}

#[cfg(any(unix, target_os = "redox"))]
pub fn osstr_to_bytes(input: &OsStr) -> Cow<'_, [u8]> {
use std::os::unix::ffi::OsStrExt;
Cow::Borrowed(input.as_bytes())
}

#[cfg(windows)]
pub fn osstr_to_bytes(input: &OsStr) -> Cow<'_, [u8]> {
let string = input.to_string_lossy();

match string {
Cow::Owned(string) => Cow::Owned(string.into_bytes()),
Cow::Borrowed(string) => Cow::Borrowed(string.as_bytes()),
}
}

/// Remove the `./` prefix from a path.
pub fn strip_current_dir(path: &Path) -> &Path {
path.strip_prefix(".").unwrap_or(path)
Expand Down
Loading
Loading