[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 19ca031a085fc84c36a9f001b33e5a28013ff79d

Ville Skyttä ville.skytta at iki.fi
Wed Jan 6 11:30:35 UTC 2010


The following commit has been merged in the master branch:
commit 19ca031a085fc84c36a9f001b33e5a28013ff79d
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Jan 6 13:27:28 2010 +0200

    Small yp-tools completion improvements.
    
    Install ypmatch completion only if ypcat is available instead of the
    other way around, fix completions when commands are invoked using
    paths to them.

diff --git a/CHANGES b/CHANGES
index b6e598a..afb2518 100644
--- a/CHANGES
+++ b/CHANGES
@@ -27,7 +27,7 @@ bash-completion (2.x)
   * Remove many unnecessary short option completions where long ones exist.
   * Improve chsh, configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
     mysqladmin, rsync, screen, service, scp, ssh, sshfs, update-alternatives,
-    vncviewer, and general hostname completions.
+    vncviewer, yp-tools, and general hostname completions.
   * Add abook and wtf completion, based on work by Raphaël Droz.
   * Add cvsps, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake, pack200
     and unpack200 completions.
diff --git a/contrib/yp-tools b/contrib/yp-tools
index 44fafeb..4644ba5 100644
--- a/contrib/yp-tools
+++ b/contrib/yp-tools
@@ -1,22 +1,24 @@
 # bash completion for yp-tools
 
-have ypmatch &&
+have ypcat &&
 _ypmatch()
 {
-    local cur map
+    local cur map cmd
 
     COMPREPLY=()
     cur=`_get_cword`
+    cmd=${1##*/}
 
-    [[ $1 == ypcat && $COMP_CWORD -gt 1 ]] && return 0
-    [[ $1 == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
+    [[ $cmd == ypcat && $COMP_CWORD -gt 1 ]] && return 0
+    [[ $cmd == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
 
-    if [[ $1 == ypmatch && $COMP_CWORD -eq 1 && ${#COMP_WORDS[@]} -eq 3 ]]; then
+    if [[ $cmd == ypmatch && $COMP_CWORD -eq 1 && \
+        ${#COMP_WORDS[@]} -eq 3 ]]; then
         map=${COMP_WORDS[2]}
         COMPREPLY=( $( compgen -W '$( ypcat $map | \
             cut -d':' -f 1 )' -- "$cur") )
     else
-        [[ $1 == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
+        [[ $cmd == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
         COMPREPLY=( $( compgen -W \
             '$( printf "%s\n" $(ypcat -x | cut -d"\"" -f 2) )' -- "$cur"))
     fi

-- 
bash-completion



More information about the Bash-completion-commits mailing list