fd
fd copied to clipboard
Unexpected behavior for the Placeholder syntax on windows powershell
What version of fd
are you using?
$ fd --version
fd 8.2.1
Context I want to list all files recursively in a directory while printing only the basename.
So instead of this:
dir1\test1.txt
dir1\test2.txt
dir2\testA.txt
I want this:
test1.txt
test2.txt
testA.txt
To my understanding, the best way to do so is to use fd -t f -x echo {/}
.
On windows cmd.exe
it works fine (but it's very slow).
fd -t f -x echo {/}
test1.txt
test2.txt
testA.txt
On windows powershell.exe
, the output is not as expected.
$ fd -t f -x echo {/}
-encodedCommand LwA= -inputFormat xml -outputFormat text dir1\test1.txt
-encodedCommand LwA= -inputFormat xml -outputFormat text dir1\test2.txt
-encodedCommand LwA= -inputFormat xml -outputFormat text dir2\testA.txt
Question
Is this a bug?
Maybe a documentation problem?
Is there a better way than fd -t f -x echo {/}
?
Question Is this a bug?
I don't think so. You need to properly escape {}
characters. Please see #646, #722, #310 for more details.
Maybe a documentation problem?
Possibly. It's not really fd
s fault. {}
always need to be escaped in PowerShell. But we could maybe make sure that all examples use a syntax that would also work in PowerShell and mention it in the troubleshooting section here: https://github.com/sharkdp/fd#troubleshooting
Is there a better way than
fd -t f -x echo {/}
?
Not really. Alternatively, you could use -x basename
, if that's available on Windows.
Hi @sharkdp, Thanks for your feedback and sorry for the duplication.
Is there a better way than fd -t f -x echo {/} ?
Not really
Yeah, this is what I thought. Not sure why it's so slow though.
Have a good day and thanks for fd
; it's a joy to use.
I am reopening this to make sure this will be updated in the documentation.