[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-267-g20a3d4d

Ville Skyttä ville.skytta at iki.fi
Wed May 4 20:21:43 UTC 2011


The following commit has been merged in the master branch:
commit 20a3d4d0bd5442776cd95f8ccd7c44da877c2ea8
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed May 4 23:21:06 2011 +0300

    rdesktop: Use _parse_help, add/improve option completions and basic test case.

diff --git a/completions/rdesktop b/completions/rdesktop
index cb83a5d..20f3b48 100644
--- a/completions/rdesktop
+++ b/completions/rdesktop
@@ -5,7 +5,7 @@ have rdesktop || return
 _rdesktop()
 {
     local cur prev words cword
-    _init_completion || return
+    _init_completion -n : || return
 
     case $prev in
         -k)
@@ -22,22 +22,33 @@ _rdesktop()
             return 0
             ;;
         -x)
-            COMPREPLY=( $( compgen -W 'b broadband m modem l lan' \
-                -- $cur ) )
+            COMPREPLY=( $( compgen -W 'broadband modem lan' -- "$cur" ) )
             return 0
             ;;
         -r)
-            # FIXME: should do -o nospace for the colon options
-            COMPREPLY=( $( compgen -W 'comport: disk: lptport: \
-                printer: sound: lspci scard' -- "$cur" ) )
+            case $cur in
+                sound:*)
+                    COMPREPLY=( $( compgen -W 'local off remote' \
+                        -- "${cur#sound:}" ) )
+                    ;;
+                *:*)
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W 'comport: disk: lptport: \
+                        printer: sound: lspci scard' -- "$cur" ) )
+                    [[ $COMPREPLY == *: ]] && compopt -o nospace
+                    ;;
+            esac
+            return 0
+            ;;
+        -u|-d|-s|-c|-p|-n|-g|-S|-T|-X)
             return 0
             ;;
     esac
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -k -g -f -b -L \
-            -A -B -e -E -m -C -D -K -S -T -N -X -a -z -x -P -r \
-            -0 -4 -5' -- "$cur" ) )
+        local opts=( $( _parse_help "$1" ) )
+        COMPREPLY=( $( compgen -W '${opts[@]%:}' -- "$cur" ) )
     else
         _known_hosts_real "$cur"
     fi
diff --git a/test/completion/rdesktop.exp b/test/completion/rdesktop.exp
new file mode 100644
index 0000000..29eddf6
--- /dev/null
+++ b/test/completion/rdesktop.exp
@@ -0,0 +1 @@
+assert_source_completions rdesktop
diff --git a/test/lib/completions/a2ps.exp b/test/lib/completions/rdesktop.exp
similarity index 78%
copy from test/lib/completions/a2ps.exp
copy to test/lib/completions/rdesktop.exp
index 77cd07f..3254494 100644
--- a/test/lib/completions/a2ps.exp
+++ b/test/lib/completions/rdesktop.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "a2ps "
+assert_complete_any "rdesktop -"
 
 
 sync_after_int

-- 
bash-completion



More information about the Bash-completion-commits mailing list