On Fri, Feb 13, 2015 at 6:04 AM, Raphaël <raphael.d...@gmail.com> wrote:
> Another try on this.

The patch should be more careful about adding additional completion
dirs, for example if BASH_COMPLETION_USER_DIR and XDG_DATA_HOME are
not set, they shouldn't be used as is.

How about the attached patch (indentation changes omitted for
readability)? I.e. use BASH_COMPLETION_USER_DIR if set, otherwise
XDG_DATA_HOME and its fallback.
diff --git a/bash_completion b/bash_completion
index e707ff5..361d3f5 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1960,14 +1960,16 @@ complete -F _minimal ''
 _completion_loader()
 {
     # $1=_EmptycmD_ already for empty cmds in bash 4.3, set to it for earlier
-    local cmd="${1:-_EmptycmD_}" compdir=./completions compfile
+    local cmd="${1:-_EmptycmD_}" compdir=./completions compfile dir
     [[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
 
+    for dir in ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share/bash-completion}}/completions $compdir; do
     for compfile in "${cmd##*/}" "${cmd##*/}".bash _"${cmd##*/}"; do
-        compfile="$compdir/$compfile"
+        compfile="$dir/$compfile"
         # Avoid trying to source dirs; https://bugzilla.redhat.com/903540
         [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 124
     done
+    done
 
     # Need to define *something*, otherwise there will be no completion at all.
     complete -F _minimal -- "$cmd" && return 124
_______________________________________________
Bash-completion-devel mailing list
Bash-completion-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-devel

Reply via email to