Closed RoggeHaj closed 3 months ago
Thanks for the report. What are the results of the following commands (after attempting the completion for the command .
)?
$ . [TAB] # <-- attempt the completion for the command . to intentionally produce error
$ complete -p .
$ declare -p BASH_COMPLETION_VERSINFO
$ complete -p .
bash: complete: .: no completion specification
$ declare -p BASH_COMPLETION_VERSINFO
declare -a BASH_COMPLETION_VERSINFO=([0]="2" [1]="8")
Does the problem reproduce after running unalias -a
?
$ unalias -a
$ . [TAB] <--- attempt completion
Yes, same as before
$ unalias -a
$ . bash: .: syntax error: operand expected (error token is ".")
Thank you. Hmm, what is the result of the following command?
$ complete -p -D
$ complete -p -D
complete -F _completion_loader -D
Thanks. I suspect _completion_loader
of bash-completion-2.8. I'll check later the behavior with bash-completion-2.8. If possible, you can try using the latest version of bash-completion-2.12.
I now tried OMB + bash-completion-2.8 + bash-4.4, but the problem doesn't seem to arise. I'd like to get a debug trace. Could you run the following commands?
$ exec 3> debug.txt; BASH_XTRACEFD=3; set -x
$ . [TAB] <-- attempt completion
$ set +x
Then, a file debug.txt
is created. Could you attach the file in reply? You can drag and drop the file into the textarea to attach a file in GitHub.
Thank you. I've checked its content. I think _xspecs
is an indexed array in your environment (instead of an associated array) for some reason.
OK, I could reproduce the problem. The problem arises when bash-completion-2.8 is loaded inside OMB. This happens because OMB sources modules inside a shell function, while bash-completion-2.8
declares the associative array _xspecs
as declare -A _xspecs
. When declare -A _xspecs
is executed inside source
called from a function, it creates a local variable _xspecs
, which disappears after the initialization. This causes the problem.
There is also a report at https://github.com/scop/bash-completion/issues/360. The fix to bash-completion
was given by https://github.com/scop/bash-completion/pull/210 and included in the release 2.9.
A workaround for bash-completion-2.8 is to source bash-completion at the top level of ~/.bashrc
:
diff --git a/templates/bashrc.osh-template b/templates/bashrc.osh-template
index 4f1851d..40e85c2 100644
--- a/templates/bashrc.osh-template
+++ b/templates/bashrc.osh-template
@@ -4,6 +4,8 @@ case $- in
*) return;;
esac
+source /usr/share/bash-completion/bash_completion
+
# Path to your oh-my-bash installation.
export OSH=~/.oh-my-bash
Works like a charm. Many thanks!
In Bash, at least on version 4.4.20(1)-release (Ubuntu 18.04), I get an error when trying to source a file with completion. I've tried with a clean install of Oh My Bash, just to rule out any custom modifications, with the same results.
Steps to reproduce
<TAB>
Expected behavior
Completion on file names and directories in current directory.
Actual behavior
OSH version
6c1bde9779841b096a88e96f43fda210b78e5ddc