[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-481-g79ac9b5

Ville Skyttä ville.skytta at iki.fi
Wed Oct 26 17:46:34 UTC 2011


The following commit has been merged in the master branch:
commit 22f88858ee658693c4cb2a76c49634360290c5b8
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Oct 26 20:44:22 2011 +0300

    _command_offset: Load undefined completions on demand.

diff --git a/bash_completion b/bash_completion
index 233616f..db1d15d 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1593,13 +1593,28 @@ _command_offset()
         compopt -o filenames
         COMPREPLY=( $( compgen -d -c -- "$cur" ) )
     else
-        local cspec cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]}
-        # Do we have full path completion for $cmd?
-        if ! cspec=$( complete -p $cmd 2>/dev/null ) && [[ $cmd == */* ]]; then
-            # Nope, what about the basename?
-            compcmd=${cmd##*/}
-            cspec=$( complete -p $compcmd 2>/dev/null )
+        local cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]}
+        local cspec=$( complete -p $cmd 2>/dev/null )
+        if [[ ! $cspec ]]; then
+            if [[ $cmd == */* ]]; then
+                # Load completion for full path
+                _completion_loader $cmd
+                if [[ $? -eq 124 ]]; then
+                    # Success, but we may now have the full path completion...
+                    cspec=$( complete -p $cmd 2>/dev/null )
+                    if [[ ! $cspec ]]; then
+                        # ...or just the basename one.
+                        compcmd=${cmd##*/}
+                        cspec=$( complete -p $compcmd 2>/dev/null )
+                    fi
+                fi
+            else
+                # Simple, non-full path case.
+                _completion_loader $cmd
+                [[ $? -eq 124 ]] && cspec=$( complete -p $cmd 2>/dev/null )
+            fi
         fi
+
         if [[ -n $cspec ]]; then
             if [ "${cspec#* -F }" != "$cspec" ]; then
                 # complete -F <function>

-- 
bash-completion



More information about the Bash-completion-commits mailing list