[Bash-completion-commits] [bash-completion] 02/04: _completion_loader: Set empty command to _EmptycmD_ for cross version compat

Ville Skyttä scop-guest at moszumanska.debian.org
Wed Sep 17 16:41:32 UTC 2014


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 7394d744aee259929012cbcd53a9c268dfe9c025
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Sep 17 19:20:29 2014 +0300

    _completion_loader: Set empty command to _EmptycmD_ for cross version compat
    
    bash 4.3 gives us _EmptycmD_ for empty commands, while earlier
    versions give us the empty string; set it to _EmptycmD_ for those as
    well for consistency.
---
 bash_completion | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/bash_completion b/bash_completion
index bfc2c55..7e01ae4 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1949,17 +1949,18 @@ complete -F _minimal ''
 # set up dynamic completion loading
 _completion_loader()
 {
-    local compdir=./completions compfile
+    # $1=_EmptycmD_ already for empty cmds in bash 4.3, set to it for earlier
+    local cmd="${1:-_EmptycmD_}" compdir=./completions compfile
     [[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
 
-    for compfile in "${1##*/}" _"${1##*/}"; do
+    for compfile in "${cmd##*/}" _"${cmd##*/}"; do
         compfile="$compdir/$compfile"
         # Avoid trying to source dirs; https://bugzilla.redhat.com/903540
         [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 124
     done
 
     # Need to define *something*, otherwise there will be no completion at all.
-    complete -F _minimal "$1" && return 124
+    complete -F _minimal "$cmd" && return 124
 } &&
 complete -D -F _completion_loader
 

-- 
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