(Go: >> BACK << -|- >> HOME <<)

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior for the Placeholder syntax on windows powershell #735

Open
g-berthiaume opened this issue Mar 2, 2021 · 3 comments
Open

Comments

@g-berthiaume
Copy link

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 {/} ?

@sharkdp
Copy link
Owner
sharkdp commented Mar 2, 2021

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 fds 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.

@g-berthiaume
Copy link
Author

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.

@sharkdp
Copy link
Owner
sharkdp commented Mar 14, 2021

I am reopening this to make sure this will be updated in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants