romkatv / zsh4humans

A turnkey configuration for Zsh
MIT License
1.81k stars 116 forks source link

z4h-fzf-history widget fails with special characters in command history #313

Closed LangLangBart closed 5 months ago

LangLangBart commented 5 months ago

When a user runs the command below and executes the z4h-fzf-history widget, an error is encountered.

To reproduce:

  1. Run

    fc -p =(print -r -- 'echo デ')
  2. Press ⌃ Control + R to execute the z4h-fzf-history widget

  3. Notice the error

z4h-fzf-history:133: no matches found: echo \M-c\n

Possible solution

Prepending noglob or unsetting either the nomatch or glob option prevents the error.

--- a/fn/z4h-fzf-history
+++ b/fn/z4h-fzf-history
@@ -131,5 +131,5 @@ local preview='printf "%s" {} | command cut -f2- -d'$'\1'
       unsetopt pipe_fail
       {
-        (( $#history )) && printf '%s\000' "${history[@]}"
+        (( $#history )) && noglob printf '%s\000' "${history[@]}"
       } | {
         {

Related: https://github.com/junegunn/fzf/pull/3855

romkatv commented 5 months ago

Thanks!

romkatv commented 5 months ago

I reported this zsh bug upsteam: https://www.zsh.org/mla/workers/2024/msg00513.html