lincheney / fzf-tab-completion

Tab completion using fzf
GNU General Public License v3.0
623 stars 40 forks source link

bash completion does not work in macos #86

Closed ziranjameshe closed 4 months ago

ziranjameshe commented 8 months ago
fzf-tab-completion/bash/fzf-bash-completion.sh: line 555: unexpected EOF while looking for matching `"'
fzf-tab-completion/bash/fzf-bash-completion.sh: line 560: syntax error: unexpected end of file
lincheney commented 8 months ago

Hello What version of bash do you have installed

ziranjameshe commented 8 months ago

Hey, tried both bash 3.2.57 and 4.4.20. Problem exist on both.

ArtBIT commented 8 months ago

Same issue here. Using macOS Sonoma v14.2 GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin23)

ggrep (GNU grep) 3.11 gsed (GNU sed) 4.9 GNU Awk 5.3.0, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)

lincheney commented 8 months ago

I can reproduce this issue on bash 3 only and not bash 4. For bash 3, can you please upgrade to a more recent version of bash

ziranjameshe commented 8 months ago

Thanks for the quick turnaround.

I am pretty sure I have tried installing the bash 4+, but seeing the same issue.

Can we not just fix the problem?

lincheney commented 8 months ago

Hi

I've tried on both bash 4.4 and 4.3 and unable to reproduce this issue. Are you able to try installing a more recent version of bash (e.g. bash 5)? Unfortunately I have limited appetite for making this work on older versions of bash that I do not run (especially bash 3!). However, if you would like to try getting it working on older versions yourself and open PR for any changes, that would also be appreciated.

ziranjameshe commented 8 months ago

Hey, just tried bash 5. I can source in the script now. Do you not get a tac: command not found error?

I think tac only available on linux.

ziranjameshe commented 8 months ago

Hey, just tried bash 5. I can source in the script now. Do you not get a tac: command not found error?

I think tac only available on linux.

Actually, I can resolve this by installing brew install coreutils. But there is some strange behaviour with sed now.

I am seeing sed: First RE may not be empty with a cd <TAB> showing all the available bash command

dhcabinian commented 8 months ago

+1 to the sed: First RE may not be empty on macOS with GNU bash, version 5.2.21(1)-release (x86_64-apple-darwin23.0.0) and showing a listing of all possible bash commands.

lincheney commented 8 months ago

if you can pinpoint which sed in the script is failing, that would be helpful If you do set -x and then try it, it should print out the commands it runs, and then you may be able to find which sed command is problematic

dhcabinian commented 8 months ago

set -x gives the following traceback: +++ printf '%s\n' ' ' +++ buffer= +++ IFS= +++ read -r line +++ case "$line" in +++ (( count < 0 )) +++ (( count > 0 )) +++ printf '%s\n' git +++ buffer= +++ IFS= +++ read -r line +++ printf '%s\n' '' sed: first RE may not be empty ++ [[ 0 -gt 1 ]] +++ printf %s ++ COMP_LINE= ++ COMP_POINT=0 ++ readarray -t COMP_WORDS +++ printf '%s\n' +++ ggrep '[^[:space:]]' ++ [[ 0 = 0 ]] ++ COMP_WORDS+=('') ++ COMP_CWORD=1 ++ (( COMP_CWORD-- ) pointing at

_fzf_bash_completion_parse_line which fails at the sed pipe here:

        | _fzf_bash_completion_flatten_subshells \
        | tr \\n \\0 \
        | "$_fzf_bash_completion_sed" -r "$(cat <<'EOF'

https://github.com/lincheney/fzf-tab-completion/blob/f6f83c88eca0fc07f7820dd8bb6c7ea75ef478c5/bash/fzf-bash-completion.sh#L126C1-L128C56

lincheney commented 7 months ago

i think this may be due to the null bytes, mac sed probably can't handle it, i 'll see if i can change it to something else

lincheney commented 7 months ago

I have pushed this https://github.com/lincheney/fzf-tab-completion/commit/9616591b74c72c0f716b214c659b2c3c91964e75, hoping it may fix some of the issues.

ziranjameshe commented 7 months ago

I have pushed this 9616591, hoping it may fix some of the issues.

Thanks for looking. It does address the above issue but this doesn't seem to fix the not working issue on MacOS.

The behaviour now is TAB won't return any match

lincheney commented 6 months ago

I have pushed this 9616591, hoping it may fix some of the issues.

I've had to revert this as it was causing other issues. Can you please try install gnu sed instead.