[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-84-g4c97896

Ville Skyttä ville.skytta at iki.fi
Wed Apr 20 11:42:48 UTC 2011


The following commit has been merged in the master branch:
commit ab29cef65a035340504d09de649515dae42a7673
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Apr 20 14:02:21 2011 +0300

    Use _init_completion() in completions/_*.

diff --git a/completions/_mock b/completions/_mock
index f7512ef..171732f 100644
--- a/completions/_mock
+++ b/completions/_mock
@@ -7,24 +7,23 @@ have mock || return
 
 _mock()
 {
-    local cur prev plugins cfgdir split=false
+    local cur prev words cword
+    _init_completion || return
 
-    COMPREPLY=()
-    _get_comp_words_by_ref cur prev
-    plugins='tmpfs root_cache yum_cache bind_mount ccache'
-    cfgdir=/etc/mock
+    local plugins='tmpfs root_cache yum_cache bind_mount ccache'
+    local cfgdir=/etc/mock count=0 i
 
-    count=0
-    for i in "${COMP_WORDS[@]}" ; do
-        [ $count -eq $COMP_CWORD ] && break
+    for i in "${words[@]}" ; do
+        [ $count -eq $cword ] && break
         if [[ "$i" == --configdir ]] ; then
-            cfgdir="${COMP_WORDS[((count+1))]}"
+            cfgdir="${words[((count+1))]}"
         elif [[ "$i" == --configdir=* ]] ; then
             cfgdir=${i/*=/}
         fi
         count=$((++count))
     done
 
+    local split=false
     _split_longopt && split=true
 
     case $prev in
diff --git a/completions/_modules b/completions/_modules
index 941ab81..c76ed66 100644
--- a/completions/_modules
+++ b/completions/_modules
@@ -46,20 +46,19 @@ _module_avail ()
 # A completion function for the module alias
 _module ()
 {
-    local cur prev options
+    local cur prev words cword
+    _init_completion || return
 
-    COMPREPLY=()
-    _get_comp_words_by_ref cur prev
-
-    if [ $COMP_CWORD -eq 1 ] ; then
+    if [ $cword -eq 1 ] ; then
         # First parameter on line -- we expect it to be a mode selection
 
+        local options
         options="$( module help 2>&1 | command grep -E '^[[:space:]]*\+' | \
                     awk '{print $2}' | sed -e 's/|/ /g' | sort )"
 
         COMPREPLY=( $(compgen -W "$options" -- "$cur") )
 
-    elif [ $COMP_CWORD -eq 2 ] ; then
+    elif [ $cword -eq 2 ] ; then
         case $prev in
             add|display|help|load|show|whatis)
                 COMPREPLY=( $(_module_avail "$cur") )
@@ -71,8 +70,8 @@ _module ()
                 COMPREPLY=( $(_module_path "$cur") )
                 ;;
         esac
-    elif [ $COMP_CWORD -eq 3 ] ; then
-        case ${COMP_WORDS[1]} in
+    elif [ $cword -eq 3 ] ; then
+        case ${words[1]} in
             swap|switch)
                 COMPREPLY=( $(_module_avail "$cur") )
                 ;;
diff --git a/completions/_subversion b/completions/_subversion
index 96e2aa0..1ae666d 100644
--- a/completions/_subversion
+++ b/completions/_subversion
@@ -7,11 +7,10 @@ have svn || return
 
 _svn()
 {
-    local cur prev commands options command
-
-    COMPREPLY=()
-    _get_comp_words_by_ref cur prev
+    local cur prev words cword
+    _init_completion || return
 
+    local commands
     commands='add blame praise annotate ann cat checkout co cleanup commit \
                 ci copy cp delete del remove rm diff di export help ? h import \
                 info list ls lock log merge mkdir move mv rename ren \
@@ -19,7 +18,7 @@ _svn()
                 proplist plist pl propset pset ps resolved revert \
                 status stat st switch sw unlock update up'
 
-    if [[ $COMP_CWORD -eq 1 ]] ; then
+    if [[ $cword -eq 1 ]] ; then
         if [[ "$cur" == -* ]]; then
             COMPREPLY=( $( compgen -W '--version' -- $cur ) )
         else
@@ -42,17 +41,18 @@ _svn()
                 return 0
                 ;;
             --editor-cmd|--diff-cmd|--diff3-cmd)
-                COMP_WORDS=(COMP_WORDS[0] $cur)
-                COMP_CWORD=1
+                words=(words[0] $cur)
+                cword=1
                 _command
                 return 0
                 ;;
         esac
 
-        command=${COMP_WORDS[1]}
+        local command=${words[1]}
 
         if [[ "$cur" == -* ]]; then
             # possible options for the command
+            local options
             case $command in
                 add)
                     options='--auto-props --no-auto-props --force --targets
@@ -220,15 +220,14 @@ complete -F _svn svn
 
 _svnadmin()
 {
-    local cur prev commands options mode
-
-    COMPREPLY=()
-    _get_comp_words_by_ref cur prev
+    local cur prev words cword
+    _init_completion || return
 
+    local commands
     commands='create deltify dump help ? hotcopy list-dblogs list-unused-dblogs
               load lslocks lstxns recover rmlocks rmtxns setlog verify'
 
-    if [[ $COMP_CWORD -eq 1 ]] ; then
+    if [[ $cword -eq 1 ]] ; then
         if [[ "$cur" == -* ]]; then
             COMPREPLY=( $( compgen -W '--version' -- $cur ) )
         else
@@ -246,10 +245,11 @@ _svnadmin()
                 ;;
         esac
 
-        command=${COMP_WORDS[1]}
+        local command=${words[1]}
 
         if [[ "$cur" == -* ]]; then
             # possible options for the command
+            local options
             case $command in
                 create)
                     options='--bdb-txn-nosync --bdb-log-keep --config-dir
@@ -293,25 +293,25 @@ complete -F _svnadmin -o default svnadmin
 
 _svnlook()
 {
-    local cur prev commands options mode
-
-    COMPREPLY=()
-    _get_comp_words_by_ref cur
+    local cur prev words cword
+    _init_completion || return
 
+    local commands
     commands='author cat changed date diff dirs-changed help ? h history info
               lock log propget pget pg proplist plist pl tree uuid youngest'
 
-    if [[ $COMP_CWORD -eq 1 ]] ; then
+    if [[ $cword -eq 1 ]] ; then
         if [[ "$cur" == -* ]]; then
             COMPREPLY=( $( compgen -W '--version' -- $cur ) )
         else
             COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
         fi
     else
-        command=${COMP_WORDS[1]}
+        local command=${words[1]}
 
         if [[ "$cur" == -* ]]; then
             # possible options for the command
+            local options
             case $command in
                 author|cat|date|dirs-changed|info|log)
                     options='-r --revision -t --transaction'
diff --git a/completions/_yum b/completions/_yum
index 5c95dd8..64989f2 100644
--- a/completions/_yum
+++ b/completions/_yum
@@ -37,14 +37,13 @@ _yum_plugins()
 
 _yum()
 {
-    local cur prev special i split=false
+    local cur prev words cword
+    _init_completion || return
 
-    COMPREPLY=()
-    _get_comp_words_by_ref cur prev
-
-    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
-        if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then
-            special=${COMP_WORDS[i]}
+    local special i
+    for (( i=0; i < ${#words[@]}-1; i++ )); do
+        if [[ ${words[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then
+            special=${words[i]}
         fi
     done
 
@@ -75,6 +74,7 @@ _yum()
         esac
     fi
 
+    local split=false
     _split_longopt && split=true
 
     case $prev in
diff --git a/completions/_yum-utils b/completions/_yum-utils
index 990e6bc..b68edac 100644
--- a/completions/_yum-utils
+++ b/completions/_yum-utils
@@ -7,10 +7,8 @@ have repomanage || return
 
 _repomanage()
 {
-    local cur prev
-
-    COMPREPLY=()
-    _get_comp_words_by_ref cur prev
+    local cur prev words cword
+    _init_completion || return
 
     [[ "$prev" == -@(h|-help|k|-keep) ]] && return 0
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list