junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
62.32k stars 2.35k forks source link

fzf adding a ^ character on Windows when an @ symbol exists in selected line/field #3764

Closed amreus closed 2 months ago

amreus commented 2 months ago

Checklist

Output of fzf --version

0.51.0 (260a65b)

OS

Shell

Problem / Steps to reproduce

Using Windows Terminal:

Command line entered:

>echo one @two three @four five s@ix |fzf  --bind "enter:execute(echo {})+abort"

Result displayed:

"one ^@two three ^@four five s^@ix "

So it appears wherever the is a @ symbol, fzf has added a ^ symbol?

junegunn commented 2 months ago

I recently revised the argument escaping for cmd.exe to fix some of the long-standing problems on Windows.

https://github.com/junegunn/fzf/blob/7bac1a761c9040542d9bd73d860fe0b9e2fb7ac5/src/util/util_windows.go#L111-L137

And it escapes @ with ^. Is this a problem for you?

junegunn commented 2 months ago

Maybe escaping @ is not really required. I'll look into it.

https://ss64.com/nt/syntax-esc.html

amreus commented 2 months ago

I'm using fzf as a front-end for youtube subscriptions - fetching xml and parsing using a Ruby script and displaying the results in fzf. One of the columns is the channel "handle" which start with the @ symbol. I am sending the handle to an executable:

--bind "delete:execute-silent(exec\mark-handle-read.exe {3})"

In this case, the .exe handles any strings passed - no escaping required. I think because fzf already quotes the result on Windows?

On the Windows cmd.exe:

prog.exe ^| tee is the same as prog.exe "|" tee

The example does not pipe - it passes the | as an argument to the program.

junegunn commented 2 months ago

Can you check if the problem is fixed on the latest source? In case you can't build the binary, I'm attaching the one I just built.

fzf.exe.zip

amreus commented 2 months ago

I tried the binary you built - it works, thank you. I had reverted to the previous version for the short term.

Is there a discussion of the need for the escaping? If fzf returns double-quoted strings in Windows, I am not sure why escaping would be needed.