junegunn / fzf

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

Remove comment in command substitution in completion.zsh #3875

Closed hexium310 closed 2 weeks ago

hexium310 commented 2 weeks ago

After 22adb6494f4957d0bcc29a821b738b4e5d5796a5, the Zsh completion using ** fails.

$ cat **__fzf_generic_path_completion:23: bad pattern: #

The cause of this bug is that a comment is in the command substitution.

LangLangBart commented 2 weeks ago

Thanks for testing it before the release. I had interactive_comments enabled, which prevented the error from occurring when I tested it.

Comments within a command substitution inside a function are not automatically removed when parsed, unlike other comments in a function. Therefore, moving the comment outside of the substitution should not trigger any error.


Options:

  1. Remove the comment (preferred)
  2. setopt localoptions interactive_comments
  3. Move the comment outside the command substitution

Option 1 seems safe, and one can use git blame to check why the line was written that way.

Option 2 should work, but who knows what kind of pitfalls this might unleash.

Option 3 makes the comment one line separated from the actual affected code line, which looks odd.


EDIT1

Related thread on the Zsh Mailing List Archive:

junegunn commented 2 weeks ago

Thanks!