[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 5eead0ebeecf7d3212df3fea9cfe0fa88b6d0274

Ville Skyttä ville.skytta at iki.fi
Sun Jul 11 11:51:27 UTC 2010


The following commit has been merged in the master branch:
commit 5eead0ebeecf7d3212df3fea9cfe0fa88b6d0274
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sun Jul 11 14:51:06 2010 +0300

    Fix p4 completion, was broken in f8bafe285e7d20fdd82f77289059dd18f78312c2 (Alioth: #312625).

diff --git a/CHANGES b/CHANGES
index 5c463ee..c65de5a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,7 @@ bash-completion (2.x)
   * Add gif to mplayer filename completions (Alioth: #312512).
   * Add "short" tarball extensions to unxz, unlzma etc completions.
   * Improve /etc/init.d/* and sqlite3 completions.
+  * Fix p4 completion (Alioth: #312625).
 
   [ Freddy Vulto ]
   * Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095)
diff --git a/contrib/p4 b/contrib/p4
index 0795a28..59b02c1 100644
--- a/contrib/p4
+++ b/contrib/p4
@@ -3,10 +3,10 @@
 have p4 &&
 _p4()
 {
-    local cur prev preprev p4commands p4filetypes
+    local cur prev words cword p4commands p4filetypes
 
     COMPREPLY=()
-    _get_comp_words_by_ref cur prev preprev
+    _get_comp_words_by_ref cur prev words cword
 
     # rename isn't really a command
     p4commands="$( p4 help commands | awk 'NF>3 {print $1}' )"
@@ -14,9 +14,9 @@ _p4()
         uresource uxbinary xbinary xltext xtempobj xtext \
         text binary resource"
 
-    if [ $COMP_CWORD -eq 1 ]; then
+    if [ $cword -eq 1 ]; then
         COMPREPLY=( $( compgen -W "$p4commands" -- "$cur" ) )
-    elif [ $COMP_CWORD -eq 2 ]; then
+    elif [ $cword -eq 2 ]; then
         case $prev in
             help)
                 COMPREPLY=( $( compgen -W "simple commands \
@@ -29,10 +29,10 @@ _p4()
             *)
                 ;;
         esac
-    elif [ $COMP_CWORD -gt 2 ]; then
+    elif [ $cword -gt 2 ]; then
         case $prev in
             -t)
-                case $preprev in
+                case ${words[$cword-2]} in
                     add|edit|reopen)
                         COMPREPLY=( $( compgen -W "$p4filetypes" -- "$cur") )
                         ;;

-- 
bash-completion



More information about the Bash-completion-commits mailing list