romkatv/zsh4humans

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

LangLangBart opened this issue · 2 comments

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 デ')
  1. Press ⌃ Control + R to execute the z4h-fzf-history widget
  2. 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: junegunn/fzf#3855

Thanks!