Conversation
There was a problem hiding this comment.
Thank you for creating the PR! This is exactly the issue that I described in #1557 (comment).
When using the new version, I also noticed a search-order problem of
_comp_loadwhen the systembash-completion < 2.18and the user'sbash-completion >= 2.18coexist. I'll later describe it. I would like to discuss it and fix issues of_comp_loadincluding it.
I was naively thinking of swapping the directory precedence of 2) and 3), and inserting the search for completions-core before 4), but I haven't yet considered it deeply enough.
|
Another issue is that when, the current
|
Or, maybe we can keep the current Or, another possibility is to search i) |
Currently, I like this idea, though I need to think about it more later. It seems to solve the main issues cleanly with the minimum change. diff --git a/bash_completion b/bash_completion
index e67cc3d51..d9c1d1cce 100644
--- a/bash_completion
+++ b/bash_completion
@@ -3508,15 +3508,17 @@ _comp_load()
shift
local -a source_args=("$@")
- local i
- for i in "${!dirs[@]}"; do
- dir=${dirs[i]}/completions
- [[ -d $dir ]] || continue
- for compfile in "$cmdname.bash" "$cmdname"; do
- _comp_load__visit_file "$dir/$compfile" && return 0
- done
+ local dir
+ for dir in "${dirs[@]}"; do
+ _comp_load__visit_file "$dir/completions/$cmdname.bash" && return 0
done
+
_comp_load__visit_file "$_comp__base_directory/completions-core/$cmdname.bash" && return 0
+
+ for dir in "${dirs[@]}"; do
+ _comp_load__visit_file "$dir/completions/$cmdname" && return 0
+ done
+
_comp_load__visit_file "$_comp__base_directory/completions-fallback/$cmdname.bash" && return 0
# Look up simple "xspec" completions |
I like how it looks too, but it contains a behavioral change: |
That is a good point. Then, how about using different rules for the user-specified completion files and the package-provided completion files?
Example Implementation: bc5dfff...4366ead Rationale for checking
|
|
That sounds mostly sane, but I think (offhand) that reading system locations before in-tree ones makes it harder to work on bash-completion as well as to replace the system installed one with a user one. |
|
#1579 is one example suffering from our current load dir precedence issues. |
Could you explain it in a bit more detail? I think that is the original intent of the present separation of the directory. The original change for the separation of in-tree completions into For the test suite of
In my understanding, replacing the system-installed one with a user one is easy because the user-provided one is searched frist in the suggestion #1569 (comment).
As I mentioned above, we already set |
That suggestion notes this happens through ...in my bashrc, and it has Just Worked: things in my home dir one get precedence without having to set any other variables. |
aa744f6 to
cfb3103
Compare
|
I've reworked this PR pretty much altogether. It documents my thoughts regarding this fairly completely I hope, and implements them in a way that is easier to read and reason. Could be it's also faster in some cases because it returns as soon as it finds what needs to be found instead of computing dirs that might never be even looked at. This is very lightly tested as it stands. |
|
Thank you for updating the PR. I have a question. In the new version, The current version still has the problem described in #1569 (comment) with a user installation of |
This might not be spot on off the bat, but it restores some of the way we used to load completions from.
In particular, before this, completions-core and completions-fallback from the bash_completion location were not attempted, which is a regression at least for my workflow: I rely on being able to modify files in my bash-completion working dir and have them take precendence over any system installed ones.