[Bash-completion-commits] [bash-completion] 01/01: __load_completion: New function, use in _completion_loader and _xfunc

Ville Skyttä scop-guest at moszumanska.debian.org
Wed Jul 15 17:53:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

scop-guest pushed a commit to branch master
in repository bash-completion.

commit cad3abfc7ec1cfc2ae17a2330bf9f23993c73f09
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Jul 15 20:53:05 2015 +0300

    __load_completion: New function, use in _completion_loader and _xfunc
    
    Effectively makes _xfunc load completion files the same way as
    _completion_loader, earlier it was more limited.
---
 bash_completion | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/bash_completion b/bash_completion
index 0aa20b6..58acb0a 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1956,21 +1956,30 @@ _minimal()
 complete -F _minimal ''
 
 
-# set up dynamic completion loading
-_completion_loader()
+__load_completion()
 {
-    # $1=_EmptycmD_ already for empty cmds in bash 4.3, set to it for earlier
-    local cmd="${1:-_EmptycmD_}" compdir=./completions compfile dir
+    local cmd="$1" 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="$dir/$compfile"
             # Avoid trying to source dirs; https://bugzilla.redhat.com/903540
-            [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 124
+            [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 0
         done
     done
 
+    return 1
+}
+
+# set up dynamic completion loading
+_completion_loader()
+{
+    # $1=_EmptycmD_ already for empty cmds in bash 4.3, set to it for earlier
+    local cmd="${1:-_EmptycmD_}"
+
+    __load_completion "$cmd" && return 124
+
     # Need to define *something*, otherwise there will be no completion at all.
     complete -F _minimal -- "$cmd" && return 124
 } &&
@@ -1986,9 +1995,7 @@ _xfunc()
     local srcfile=$1
     shift
     declare -F $1 &>/dev/null || {
-        local compdir=./completions
-        [[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
-        . "$compdir/$srcfile"
+        __load_completion "$srcfile"
     }
     "$@"
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git



More information about the Bash-completion-commits mailing list