akinomyoga/ble.sh

From last update no bash completion ( only into singularity container )

Closed this issue · 14 comments

bash version: 5.2.15(1)-release (x86_64-pc-linux-gnu)
ble.sh version: 0.4.0-devel4+31f264ad

From my last update of ble.sh i have no bash completion when i'm into bash inside a singularity container.

when type 'vi ./[TAB]' the './' char is deleted from prompt.

This is same for some command like 'tar, cd, ls, cat' but not all like 'source'

No problem on host only inside container.

On host complete -p vi:

complete -F _fzf_path_completion vi

Inside container

complete -o bashdefault -o default -F _fzf_path_completion vi

I cannot reproduce the problem with the provided complete -p vi settings. Which version of fzf do you use?

  • Q1: Could you provide the output of the following command?
$ ble/widget/display-shell-version

fzf version is the same on host or container ( installed in home directory )

0.55.0 (fc69308)
  • Q1: Could you provide the output of the following command?

Inside container:

[] 🠶 ble/widget/display-shell-version
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu) [Debian GNU/Linux trixie/sid]
ble.sh, version 0.4.0-devel4+31f264ad (noarch) [git 2.45.0, GNU Make 4.3, GNU Awk 5.2.1, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)]
bash-completion, version 2.14.0 (hash:480ffcc6a751e55621ec526eb5dea7a0d86d9e72, 17877 bytes) (noarch)
fzf key-bindings, version +3c40b1bd (noarch) (integration: on)
fzf completion, version +3c40b1bd (noarch) (integration: on)
starship, version 1.12.0-master (rustc 1.65.0 (897e37553 2022-11-02), 2022-12-13 16:12:30 +00:00)
locale: LANG=en_US.UTF-8
terminal: TERM=tmux-256color wcwidth=15.1-west/16.0-2+ri, tmux:0 (84;0;0)
options: +extglob +histappend -hostcomplete +inherit_errexit

On host:

[] 🠶 ble/widget/display-shell-version
GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu) [Debian GNU/Linux trixie/sid]
ble.sh, version 0.4.0-devel4+31f264ad (noarch) [git 2.45.0, GNU Make 4.3, GNU Awk 5.2.1, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)]
bash-completion, version 2.14.0 (hash:480ffcc6a751e55621ec526eb5dea7a0d86d9e72, 17877 bytes) (noarch)
fzf key-bindings, version +3c40b1bd (noarch) (integration: on)
fzf completion, version +3c40b1bd (noarch) (integration: on)
starship, version 1.12.0-master (rustc 1.65.0 (897e37553 2022-11-02), 2022-12-13 16:12:30 +00:00)
locale: LANG=C.UTF-8
terminal: TERM=tmux-256color wcwidth=15.1-west/16.0-2+ri, tmux:0 (84;0;0)
options: +extglob +histappend -hostcomplete +inherit_errexit

Thank you for the information. The versions of fzf and bash-completion are the same in my environment, yet I cannot reproduce the problem.

GNU bash, version 5.2.26(1)-release (x86_64-redhat-linux-gnu) [Fedora Linux 39 (Server Edition)]
ble.sh, version 0.4.0-devel4+6de4d671 (noarch) [git 2.46.0, GNU Make 4.3, GNU Awk 5.2.2, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.0-p12, GNU MP 6.2.1)]
bash-completion, version 2.14.0 (hash:480ffcc6a751e55621ec526eb5dea7a0d86d9e72, 17877 bytes) (noarch)
fzf completion, version +3c40b1bd (noarch) (integration: on)
locale: LANG=ja_JP.UTF-8
terminal: TERM=screen.xterm-256color wcwidth=16.0-emacs/16.0-2+ri, screen:49900 (83;49900;0), contra:0 (99;0)
options: +extglob +histappend -hostcomplete +inherit_errexit

Another thing I noticed is that the completion setting obtained by complete -p vi changes after an attempt of completion, so the difference you saw in host and container might be unrelated.

$ complete -p vi
complete -o bashdefault -o default -F _fzf_path_completion vi
$ vi ./[TAB]
$ complete -p vi
complete -F _fzf_path_completion vi
  • Q3: What are the results of the following commands?
$ vi ./[TAB]     # <-- Please first reproduce the problem. After that, run the following commands
$ complete -p vi
$ declare -p _fzf_orig_completion_vi
$ type _fzf_handle_dynamic_completion

Thank you for your time.

After problem occur:

[] 🠶 complete -p vi
complete -F _fzf_path_completion vi
[] 🠶 declare -p _fzf_orig_completion_vi
declare -- _fzf_orig_completion_vi="complete -F %s vi #_comp_complete_filedir_xspec"
[] 🠶 type _fzf_handle_dynamic_completion
_fzf_handle_dynamic_completion is a function
_fzf_handle_dynamic_completion ()
{
    ble/function#advice/.proc "$FUNCNAME" "$@"
}
  • Q3: Can you add the following temporary settings in ~/.blerc, start a new session, and reproduce the problem by inputting vi ./TAB? Then, could you immediately close the session?
# blerc

bleopt complete_auto_complete=
function _debug {
  local - BASH_XTRACEFD=3
  set -x
  ble/function#advice/do
  declare -p COMPREPLY >&3
} 3>> ~/blesh-gh523-xtrace.txt
ble-import -C 'ble/function#advice around _fzf_path_completion _debug' integration/fzf-completion

A file should be created at ~/blesh-gh523-xtrace.txt. Could you attach the file here? After attaching the created file, you can remove the created file and remove the above code in ~/.blerc.

Very strange this fix the problem. Now when enter [TAB] i have fzf completion menu
blesh-gh523-xtrace.txt

Thank you!

Very strange this fix the problem.

Hmm, one possibility is that the problem only happens when the completion is attempted in an empty directory (where no files exist except for dotfiles), though I still cannot reproduce it in an empty directory. Another possibility is that it only happens when auto-complete is enabled.

  • Q4: Instead of the previous one, could you add this to ~/.blerc?
# blerc

rm -f ~/.blesh-gh523-xtrace.txt ~/blesh-gh523-xtrace.txt
bleopt complete_auto_complete=1
function _debug {
  if [[ :$comp_type: == *:auto:* ]]; then
    ble/function#advice/do
  else
    {
      local - BASH_XTRACEFD=3
      declare -p COMP_WORDS COMP_CWORD >&3
      set -x
      ble/function#advice/do
      declare -p COMPREPLY >&3 2>/dev/null
    } 3>> ~/.blesh-gh523-xtrace.txt
  fi
}
ble-import -C 'ble/function#advice around _fzf_path_completion _debug' integration/fzf-completion

Then could you start a new session and attempt

$ mkdir empty
$ cd empty
$ vi ./[TAB][C-u][C-d]

A new file ~/.blesh-gh523-xtrace.txt would be created (I added . at the beginning of the file in case the log file might interfere). Could you attach the created file .blesh-gh523-xtrace.txt?

Very strange this fix the problem. Now when enter [TAB] i have fzf completion menu blesh-gh523-xtrace.txt

Seem this will not fix for cd command only vi,cat, ls.

Without Q3 blerc:

  • [vi|cat|ls] [TAB] --> append space at end of command
  • [vi|cat|ls] ./[TAB] --> replace './' with space
  • cd [TAB] --> nothing
  • cd ./[TAB] --> replace './' with space

With Q3 blerc:

  • cd [TAB] --> nothing append
  • cd ./[TAB] --> render 'cd -' on prompt

I will test with Q4 question

The complete blerc file content with Q3

# -*- mode: sh; mode: sh-bash -*-
ble-color-setface disabled        fg=gray,italic
ble-color-setface syntax_comment  fg=cyan
ble-color-setface auto_complete   fg=blue,italic
ble-color-setface filename_other  fg=003
ble-color-setface region_insert fg=blue,bg=252
bind 'set completion-ignore-case on'

# Disable exit code starship prompt doing this
bleopt exec_errexit_mark=

#bleopt history_share=1

_ble_contrib_fzf_base=/home/${USER}/Documents/git/github/fzf
ble-import -d integration/fzf-completion
ble-import -d integration/fzf-key-bindings
ble-import -d integration/fzf-menu

bleopt complete_auto_complete=
function _debug {
  local - BASH_XTRACEFD=3
    set -x
      ble/function#advice/do
        declare -p COMPREPLY >&3
        
} 3>> ~/blesh-gh523-xtrace.txt
ble-import -C 'ble/function#advice around _fzf_path_completion _debug' integration/fzf-completion

Testing process:

  • update blerc
  • start new tmux pane
  • start singularity instance
singularity instance start -B /run/user/1000 ~/singularity_images/xxx.img test
  • Enter into singularity container
singularity exec instance://test /bin/bash
  • Run somme command into ~ directory ( vi/cat/ls/cd)

Result with Q4 blerc:

With Q4 blerc:

cd [TAB] --> nothing append
cd ./[TAB] --> render 'cd ' on prompt

blesh-gh523-xtrace.txt

With Q4 blerc:

cd [TAB] --> nothing append
cd ./[TAB] --> render 'cd ' on prompt

The test code in Q4 is for the vi command. Could you test it with the vi command? Or if the problem doesn't arise for the vi command with the Q4 setting, could you use the following setting for cd (there is a difference in the target function name on the last line)?

rm -f ~/.blesh-gh523-xtrace.txt ~/blesh-gh523-xtrace.txt
bleopt complete_auto_complete=1
function _debug {
  if [[ :$comp_type: == *:auto:* ]]; then
    ble/function#advice/do
  else
    {
      local - BASH_XTRACEFD=3
      declare -p COMP_WORDS COMP_CWORD >&3
      set -x
      ble/function#advice/do
      declare -p COMPREPLY >&3 2>/dev/null
    } 3>> ~/.blesh-gh523-xtrace.txt
  fi
}
ble-import -C 'ble/function#advice around _fzf_dir_completion _debug' integration/fzf-completion

I don't reproduce with tiny container from debian bookworm or sid.
So i think the problem is only on my work container.
If I find something i will put here.

My working container contain a lot of thing as tools but also lot of alias bash function

I have rebuild base image (debian sid) and my work container works again.