fd icon indicating copy to clipboard operation
fd copied to clipboard

-x option with basename format doesn't seem to work with extensions with two `.` in them

Open wegry opened this issue 4 years ago • 4 comments

What version of fd are you using? fd 8.2.1

I'm trying to find TypeScript files (.ts) that have the same basename as a TypeScript declaration file.

fd --extension 'd.ts' -x ls {.}.ts

This outputs basename.d.d.ts in zsh. is this it possible to output basename.d.ts?

wegry avatar Dec 23 '21 19:12 wegry

I think that would probably require either a separate format, or an option to enable that behavior, because it is also fairly common to have filenames where there is a . in the basename that should be included.

Or maybe if the {.} format is used and there is also an --extensions option that includes a dot, then that suffix should be removed if it matches?

tmccombs avatar Dec 24 '21 07:12 tmccombs

@tmccombs

Or maybe if the {.} format is used and there is also an --extensions option that includes a dot, then that suffix should be removed if it matches?

This is what I'd expect, I think.

wegry avatar Dec 28 '21 15:12 wegry

Hm. I would rather argue that the behavior should not not change, just because there is a --extension filter. I think that might be unexpected.

I would propose that we introduce a new format for this. How about . for removing a single file extension (like we do already) and .. for removing all file extensions? We would then add both {..} and {/..}.

sharkdp avatar Jan 23 '22 12:01 sharkdp

That seems reasonable to me

tmccombs avatar Jan 23 '22 19:01 tmccombs