Skip to content

fix: keep the ./ prefix in {} placeholders for names that start with - - #2243

Merged
tmccombs merged 1 commit into
sharkdp:masterfrom
r00tkrnl:fix-dash-prefix-in-placeholders
Nov 28, 2026
Merged

tmccombs merged 1 commit into
sharkdp:masterfrom
r00tkrnl:fix-dash-prefix-in-placeholders

Conversation

@r00tkrnl

Copy link
Copy Markdown
Contributor

fixes 2236

fd adds a ./ prefix to a path that starts with a dash so an exec command does not read it as an option. remove_extension stripped that prefix again so the placeholder without the extension turned ./-rf.jpg into -rf

it now keeps the prefix when the stripped name would start with a dash. same check stripped_path already does

added two unit tests in src/fmt/input.rs for ./-rf.jpg and dir/-rf.jpg and a changelog line

165 unit tests pass. i could not run the integration tests here because they need symlink privileges on this windows box so they all fail at setup with error 1314 before running anything

checked by hand with the built binary in a temp dir. ./-rf.jpg now gives ./-rf and a normal file is unchanged

fd adds a `./` prefix to a path that starts with `-` so an `--exec` command
does not read it as an option. `remove_extension` stripped the prefix again,
so `{.}` turned `./-rf.jpg` into `-rf` and let a file name inject an option
into the command. It now keeps the prefix whenever the stripped name would
start with `-`, the same check `DirEntry::stripped_path` already does.

Closes sharkdp#2236

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
@tmccombs
tmccombs merged commit c74413f into sharkdp:master Nov 28, 2026
20 checks passed
pei711 pushed a commit to pei711/fd that referenced this pull request Dec 1, 2026
…d names

The fix for sharkdp#2236 landed in sharkdp#2243; this keeps the end-to-end CLI
regression test from sharkdp#2246, rebased on current master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants