fzf icon indicating copy to clipboard operation
fzf copied to clipboard

/home/{user}/.fzf/shell/key-bindings.zsh:emulate:35: unknown argument -o

Open fluency03 opened this issue 5 years ago • 7 comments

  • [x] I have read through the manual page (man fzf)
  • [x] I have the latest version of fzf
  • [x] I have searched through the existing issues

Info

  • OS
    • [x] Linux
    • [ ] Mac OS X
    • [ ] Windows
    • [ ] Etc.
  • Shell
    • [ ] bash
    • [x] zsh
    • [ ] fish

Problem / Steps to reproduce

I have followed the instruction to install fzf using git way.

I have selected to use key binding.

After installation and source ~/.zshrc, I have this error:

/home/{my-user-name}/.fzf/shell/key-bindings.zsh:emulate:35: unknown argument -o

And it keeps popping up every time I login to the host.

fluency03 avatar Jun 24 '20 22:06 fluency03

zsh --version?

junegunn avatar Jun 25 '20 11:06 junegunn

zsh 5.7.1 (x86_64-pc-linux-gnu)

fluency03 avatar Jun 25 '20 13:06 fluency03

I can't reproduce the problem, tested on zsh 5.4 and 5.8

$ echo $ZSH_VERSION
5.4.2
$ source ~/.fzf.zsh
$ bindkey | grep fzf
"^I" fzf-completion
"^R" fzf-history-widget
"^T" fzf-file-widget
"^[c" fzf-cd-widget

junegunn avatar Jun 29 '20 13:06 junegunn

I have this correctly:

~ ➜ bindkey | grep fzf
"^I" fzf-completion
"^R" fzf-history-widget
"^T" fzf-file-widget
"^[c" fzf-cd-widget

But I just keeps getting the error when logon to the host:

/home/{user}/.fzf/shell/key-bindings.zsh:emulate:35: unknown argument -o

fluency03 avatar Jun 30 '20 13:06 fluency03

I too see the same error whenever I do login: /home/$USER/fzf/shell/key-bindings.zsh:emulate:35: unknown argument -o

rohanghige avatar Jan 15 '21 13:01 rohanghige

+1 . I see this error too. Any workarounds ?

shivshnkr avatar Feb 21 '21 06:02 shivshnkr

Same issue. zsh --version: zsh 4.3.11 (x86_64-redhat-linux-gnu) fzf is the latest.

$ cat /etc/centos-release CentOS release 6.9 (Final)

image

pplmx avatar Sep 20 '22 06:09 pplmx

Same issue. zsh --version: zsh 4.3.11 (x86_64-redhat-linux-gnu) fzf is the latest.

$ cat /etc/centos-release CentOS release 6.9 (Final)

image

I have the same problem withe the exact same output.

izxle avatar Oct 06 '23 22:10 izxle

I can't reproduce the problem, tested on zsh 5.4 and 5.8

Confirmed, with the default zsh version or the latest brew version the issue is not reproducible on macOS.


Building zsh from source
  • instructions: https://sourceforge.net/p/zsh/code/ci/master/tree/INSTALL
  1. clone
git clone https://git.code.sf.net/p/zsh/code zsh-code 
cd zsh-code 
  1. pre-configure If the configure script does not already exist -- e.g., if you've got a snapshot of the bare sources just checked out from a git repository -- some things need to be built before the configuration can proceed. Run the script ./Util/preconfig to do this.
./Util/preconfig
  1. Configure
  • define the location where the binary shall be placed
./configure --prefix=$HOME/.local/zsh-test
  1. check out the desired commit/tag
git checkout zsh-4.3.17 
  1. Make the binary
make && make install.bin
  1. Optionally add the binary to your PATH
# .zshrc
export PATH="$HOME/.local/zsh-test/bin:$PATH"
  1. Run the binary
zsh --version
# zsh 4.3.17 (x86_64-apple-darwin19.6.0)

I can produce the error by running the following command with zsh version 4.3.17 non-interactively.

zsh --version
# zsh 4.3.17-dev-0 (x86_64-apple-darwin19.6.0)

# prints the current options flags set for that shell session
zsh -c 'echo $-'
# 569Xd

zsh -c 'source /Users/paria/Developer/fzf/shell/key-bindings.zsh'
# /Users/paria/Developer/fzf/shell/key-bindings.zsh:emulate:35: unknown argument -o
❯ git tag --sort="-creatordate" --format="%(creatordate:format:%d/%b/%y) - %(refname:short)" | grep -C 2 'zsh-4.3.17'
# 16/Dec/12 - zsh-5.0.0-test-1
# 21/Jul/12 - zsh-5.0.0
# 15/Jul/12 - zsh-4.3.17-test-2
# 23/Feb/12 - zsh-4.3.17
# 20/Feb/12 - zsh-4.3.16
# 17/Dec/11 - zsh-4.3.15

When bisecting the zsh source code the issue was fixed with zsh / Code / Commit [fa8a0e] (7/Mar/12)

# Commit [fa8a0e]
git checkout fa8a0e >/dev/null
make install.bin >/dev/null
zsh -c 'source ~/Developer/fzf/shell/key-bindings.zsh'

# Commit prior to [fa8a0e]
git checkout fa8a0e^ >/dev/null
make install.bin >/dev/null
zsh -c 'source /Users/paria/Developer/fzf/shell/key-bindings.zsh'
# /Users/paria/Developer/fzf/shell/key-bindings.zsh:emulate:35: unknown argument -o

  • the line was added with #1944
    • merged in b1b916ce157df4fe1299edfdd012676419e2263c
'emulate' 'zsh' '-o' 'no_aliases'
  • @romkatv can you help here ?

workaround

wget -qO key-zsh-old.zsh https://raw.githubusercontent.com/junegunn/fzf/18261fe31cf1270f9aa783f99bbdbca343f89479/shell/key-bindings.zsh

zsh --version
zsh -c 'source key-zsh-old.zsh '

LangLangBart avatar Oct 07 '23 10:10 LangLangBart

~~possible fix, check if interactive~~ EDIT: No, this is not the right fix.

--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -32,7 +32,7 @@ else
   }
 fi
 
-'emulate' 'zsh' '-o' 'no_aliases'
+[[ -o interactive ]] && 'emulate' 'zsh' '-o' 'no_aliases'
 
 {

EDIT: use two lines

--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -32,7 +32,8 @@ else
   }
 fi
 
-'emulate' 'zsh' '-o' 'no_aliases'
+builtin emulate  zsh
+builtin setopt no_aliases
 
 {

LangLangBart avatar Oct 07 '23 10:10 LangLangBart

'emulate' 'zsh' '-o' 'no_aliases'
  • @romkatv can you help here ?

The -o flag was added to emulate in zsh 5.0.2. If you want to support zsh older than that, you'll have to avoid this flag and use setopt to set options.

'builtin' 'emulate' 'zsh' && 'builtin' 'setopt' 'no_aliases'

romkatv avatar Oct 08 '23 07:10 romkatv