[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-235-g26ae770

Igor Murzov igor at gplsoft.org
Mon May 2 10:27:42 UTC 2011


The following commit has been merged in the master branch:
commit 98f6b5e1a381cd30e11f2b7328f725bc0a9cea96
Author: Igor Murzov <igor at gplsoft.org>
Date:   Sun Dec 26 19:26:21 2010 +0300

    Further improve completion for sbopkg
    
    words now initialized properly; simple completions moved to the top,
    so they won't fail if some problem with config occur;
    and some other minor fixes

diff --git a/completions/slackware b/completions/slackware
index 4d955f1..7e35743 100644
--- a/completions/slackware
+++ b/completions/slackware
@@ -163,7 +163,29 @@ _sbopkg()
         return 0
     fi
 
+    case $prev in
+        -e)
+            COMPREPLY=( $( compgen -W 'ask continue stop' -- "$cur" ) )
+            return 0
+            ;;
+        -f)
+            _filedir
+            return 0
+            ;;
+        -d)
+            _filedir -d
+            return 0
+            ;;
+        -s|-g)
+            # argument required but no completions available
+            return 0
+            ;;
+    esac
+
     local config="/etc/sbopkg/sbopkg.conf"
+    local words
+    _get_comp_words_by_ref words
+
     for (( i=${#words[@]}-1; i>0; i-- )); do
         if [[ ${words[i]} == '-f' ]]; then
             config="${words[i+1]}"
@@ -178,33 +200,21 @@ _sbopkg()
 
     for (( i=${#words[@]}-1; i>0; i-- )); do
         if [[ ${words[i]} == '-V' ]]; then
-            REPO_NAME=`echo ${words[i+1]} | cut -f1 -d/`
-            REPO_BRANCH=`echo ${words[i+1]} | cut -f2 -d/`
+            REPO_NAME="${words[i+1]%%/*}"
+            REPO_BRANCH="${words[i+1]#*/}"
         fi
     done
 
     case $prev in
-        -e)
-            COMPREPLY=( $( compgen -W 'ask continue stop' -- "$cur" ) )
-            return 0
-            ;;
-        -f)
-            _filedir
-            return 0
-            ;;
-        -d)
-            _filedir -d
-            return 0
-            ;;
-        -s|-g)
-            return 0
-            ;;
         -V)
             COMPREPLY=( $( compgen -W "? \
                 `sbopkg -V ? 2>&1 | tail -n +2 | cut -f1`" -- "$cur" ) )
             return 0
             ;;
         -i|-b)
+            if [ ! -r "$REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT" ]; then
+                return 0
+            fi
             COMPREPLY=( $( grep "^SLACKBUILD NAME: $cur" \
             $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT | cut -f3- -d\  ) )
             return 0

-- 
bash-completion



More information about the Bash-completion-commits mailing list