junegunn / fzf-git.sh

bash and zsh key bindings for Git objects, powered by fzf
520 stars 47 forks source link

when I source fzf-git.sh in zsh, it exits with exitcode=1 #7

Closed balta2ar closed 1 year ago

balta2ar commented 1 year ago

If I put:

source $HOME/path/to/fzf-git.sh/fzf-git.sh

I can't even open a shell because it exist immediately:

$ source $HOME/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh
$ echo $?
1

but it works with bash. my versions:

Ubuntu 22.04.1 LTS
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

→ git show --summary
commit d9c0458ba0a32560e7df6ee202555d5247705207 (HEAD -> main, origin/main, origin/HEAD)
Author: Junegunn Choi <junegunn.c@gmail.com>
Date:   Wed Aug 24 13:11:25 2022 +0900

    Use ALT-{A,E} instead of CTRL-{A,E}

    Aren't we all too used to using CTRL-A and CTRL-E to move cursor around?
junegunn commented 1 year ago

I presume you have set -u somewhere in your zsh configuration. You probably shouldn't do it (http://mywiki.wooledge.org/BashFAQ/112), but I updated the code so that it doesn't terminate the process even when it's set.

balta2ar commented 1 year ago

I dind't have set -u in my zshrc, at least not explicitly. I tried doing this:

set +u
set -x
source $HOME/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh
set +x

and I got:

+/home/user/.zshrc:665> source /home/user/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh
+/home/user/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh:23> [[ 1 -eq 1 ]]
+/home/user/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh:33> case nobeep (branches)
+/home/user/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh:33> case nobeep (all-branches)
+/home/user/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh:33> case nobeep (refs)
+/home/user/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh:33> case nobeep (all-refs)
+/home/user/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh:33> case nobeep (*)
+/home/user/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh:50> exit 1

and then I added echo here (line 33):

  echo "$#, $*, $1"
  case "$1" in

and then I got:

+/home/username/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh:33> echo '1, nobeep, nobeep'
1, nobeep, nobeep

does that help?

junegunn commented 1 year ago

Why is nobeep in the argument list? What is that? Did you redefine source? Is it an alias or something? (type source)

balta2ar commented 1 year ago

no, nothing that I'm aware of:

$ type source
source is a shell builtin
balta2ar commented 1 year ago

I had this up above the fzf-git part in the zshrc:

unset beep
set nobeep

commenting it out helped, fzf-git started working then.

junegunn commented 1 year ago

Okay, I do not understand why zsh is pushing nobeep into $@, but I can reproduce the situation.