Skip to content

{q} isn't escaped properly on Windows #3789

@ibhagwan

Description

@ibhagwan

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.52.0 (bcda25a)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

Follwing up on #3626, we now have a different issue.

I found the current escaping sequence isn't yet working properly, while the command described in #3626 (basically, "live grep") is working it will only work when {q} is the last argument of the command.

Consider we want to display rg error messages inside fzf, we have to redirect the error stream to stdout by adding 2>&1:

fzf --ansi --disabled --bind="change:reload:rg --line-number --column --color=always {q} 2>&1"

Now if we have an open \ we see the error inside fzf (instead of "Command failed: ... "):
image

But since {q} isn't escaped properly if we try to search for a single " , the command fails:
image

Another use-case where this fails is if we want to silently fail rg and never display "Command failed", we could do that by adding || break (similar to || true on UNIX):

fzf --ansi --disabled --bind="change:reload:rg --line-number --column --color=always {q} || break"

Again, if we search for " the command will fail:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions