szermatt / emacs-bash-completion

Add programmable bash completion to Emacs shell-mode
GNU General Public License v2.0
279 stars 33 forks source link

Failure to Complete #71

Closed phikal closed 3 hours ago

phikal commented 2 weeks ago

Hi, I was trying to complete a directory path ~/Doc to ~/Documents using M-x shell, but instead I got this error message:

commandline: <<EOF
__emacs_complete_pre_command; function __emacs_complete_pre_command {  if [[ -z "$__emacs_complete_ps1" ]]; then    __emacs_complete_ps1="$PS1";    __emacs_complete_pc="$PROMPT_COMMAND";  fi;  PROMPT_COMMAND=__emacs_complete_prompt;  if [[ ${BASH_VERSINFO[0]} -eq 5 && ${BASH_VERSINFO[1]} -ge 1 || ${BASH_VERSINFO[0]} -gt 5 ]]; then  history -d $HISTCMD &>/dev/null || true;else  history -d $((HISTCMD - 1)) &>/dev/null || true;fi;} &&function __emacs_complete_prompt {  PS1='    $?';  PROMPT_COMMAND=__emacs_complete_recover_prompt;} &&function __emacs_complete_recover_prompt {  local r=$?;  PS1="${__emacs_complete_ps1}";  PROMPT_COMMAND="${__emacs_complete_pc}";  unset __emacs_complete_ps1 __emacs_complete_pc;  if [[ -n "$PROMPT_COMMAND" ]]; then    (exit $r); eval "$PROMPT_COMMAND";  fi;} &&__emacs_complete_pre_command
EOF

error: "timeout"

buffer-string: <<EOF
bash: __emacs_complete_pre_command: command not found...
EOF

process: #<process shell>

output-buffer: <<EOF
bash: __emacs_complete_pre_command: command not found...
    0EOF

emacs-version: "30.0.50"

I have had a similar issue from time to time, but haven't been able to identify what the root cause is. Does the above give any hints? My Bash version is

$ bash --version
GNU bash, version 5.2.26(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
jessie-hu-95 commented 3 days ago

I have similar issue when I connect through TRAMP. I have a customized prompt.

phikal commented 3 hours ago

My prompt is just a dollar sign, and this occurs locally. That being said, I do notice that the issue appears to disappear when I rename my .bashrc to something else, which Bash won't load.

After experimenting a bit, I pulled out this block from by .bashrc:

if [ -f /etc/bashrc ]
then
    . /etc/bashrc
fi

and added that to my .bash_profile. This had the same effect as disabling .bashrc, but now my regular terminal didn't do any completion. This could be fixed by enabling the "Run command as login shell" option, in GNOME terminal.