[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-380-g9e4605b

Ville Skyttä ville.skytta at iki.fi
Sat Jun 18 12:54:00 UTC 2011


The following commit has been merged in the master branch:
commit 9f7b2d6eebbf6009676305ca4eeb398c5c408912
Author: Raphaël Droz <raphael.droz+floss at gmail.com>
Date:   Mon Jun 13 13:48:18 2011 +0200

    better use of _parse_help and compopt for mysql(1).

diff --git a/completions/mysql b/completions/mysql
index dbf81a0..aabffd9 100644
--- a/completions/mysql
+++ b/completions/mysql
@@ -4,12 +4,8 @@ have mysql || return
 
 _mysql()
 {
-    local cur prev split=false
-
-    COMPREPLY=()
-    _get_comp_words_by_ref cur prev
-
-    _split_longopt && split=true
+    local cur prev words cword split=false
+    _init_completion -n = || return
 
     case $prev in
         -u|--user)
@@ -17,7 +13,7 @@ _mysql()
             return 0
             ;;
         -D|--database)
-            COMPREPLY=( $( compgen -W "$(mysqlshow|sed -ne '2d' -e 's/^|.\([^|]\+\)|.*/\1/p')" -- "$cur" ) )
+            COMPREPLY=( $( compgen -W "$(mysqlshow 2>/dev/null|sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur" ) )
             return 0
             ;;
 
@@ -51,7 +47,8 @@ _mysql()
         --ssl-ca|--ssl-cert|--ssl-cipher|--ssl-key|\
         --connect_timeout|max_allowed_packet|--prompt|\
         --net_buffer_length|--select_limit|--max_join_size|\
-        --server-arg|--debug|--delimiter|--execute|-e|--pager)
+        --server-arg|--debug|--delimiter|--execute|-e|--pager|\
+	--password|-p)
             # Argument required but no completions available
             return 0
             ;;
@@ -61,9 +58,11 @@ _mysql()
             ;;
     esac
 
-    $split && return 0
+    local help=$(_parse_help "$1"|sed -e '/--password/s/$/=/')
+    help+=" --skip-comment --skip-ssl"
 
-    COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+    COMPREPLY=( $( compgen -W "$help" -- "$cur" ) )
+    [[ $COMPREPLY == *= ]] && compopt -o nospace
 } &&
 complete -F _mysql mysql
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list