fd icon indicating copy to clipboard operation
fd copied to clipboard

In MSYS, `fd --glob` fails whenever a path separator is present

Open Myrdden opened this issue 1 year ago • 3 comments

So here's the directory I'm messing about with

Pictures/Backgrounds/1.jpg
Pictures/Backgrounds/2.jpg
Pictures/Backgrounds/3.jpg
Pictures/1.jpg

And here's some results:

λ fd -u -g 'Pictures'
Pictures/
λ fd -u -g 'Backgrounds'
Pictures/Backgrounds/
λ fd -u -g '1*'
Pictures/1.jpg
Pictures/Backgrounds/1.jpg
λ fd -u -g 'Pictures/1*'
(Nothing)
λ fd -u -g 'Pictures/1.jpg'
(Nothing)
λ fd -u -g 'Pictures/Backgrounds'
(Nothing)
λ fd -u -g 'Pictures/Backgrounds/*'
(Nothing)
λ fd -u -g 'Pictures/**'
(Nothing)
λ fd -u -g '*/*'
(Nothing)

(I then went through and tried all of the failing commands above with \, \\, and \/, all had the same result)

So as you can kind of see, whenever there's a path separator, fd just never returns anything. This also happens when using --full-path, with and without **/ prefixed.

EDIT: Okay, realised I was missing some info. Although I'm running in MSYS, the fd executable is the Windows release available via scoop.sh, which I believe is the msvc version. So, I tried this in Windows PowerShell, found the exact same result, and then tried in Windows CMD, and the glob option didn't do anything at all (which is probably a separate issue). I also downloaded and tested using the gnu version, and the result is the same.

Myrdden avatar Jan 08 '23 12:01 Myrdden

I think you need to use both --full-path and use the correct path separator ("").

tmccombs avatar Jan 08 '23 16:01 tmccombs

As mentioned I tried with and without --full-path and with every kind of path separator I could think of. I also have tried setting --path-separator and that makes no difference.

Myrdden avatar Jan 08 '23 16:01 Myrdden

I believe the solution here is you need the full ABSOLUTE path, not the "full path". The command name by itself suggests to me the full relative path (which is not an option unfortunately).

 -p, --full-path                  Search full abs. path (default: filename only)
mcmah309@DESKTOP-CVL0FVG:/mnt/c/Work/obelisk$ fd -g test
test/
lib/src/obelisk_document/data/building/post_processing/test/
mcmah309@DESKTOP-CVL0FVG:/mnt/c/Work/obelisk$ fd -g lib/**/test
mcmah309@DESKTOP-CVL0FVG:/mnt/c/Work/obelisk$ fd -g **/lib/**/test
mcmah309@DESKTOP-CVL0FVG:/mnt/c/Work/obelisk$ fd -gp lib/**/test
mcmah309@DESKTOP-CVL0FVG:/mnt/c/Work/obelisk$ fd -gp **/lib/**/test
lib/src/obelisk_document/data/building/post_processing/test/

mcmah309 avatar Sep 13 '23 18:09 mcmah309