handle properly long options in mysql(1).
This commit is contained in:
parent
9f7b2d6eeb
commit
d355178d87
@ -4,8 +4,8 @@ have mysql || return
|
|||||||
|
|
||||||
_mysql()
|
_mysql()
|
||||||
{
|
{
|
||||||
local cur prev words cword split=false
|
local cur prev words cword split
|
||||||
_init_completion -n = || return
|
_init_completion -s || return
|
||||||
|
|
||||||
case $prev in
|
case $prev in
|
||||||
-u|--user)
|
-u|--user)
|
||||||
@ -45,7 +45,7 @@ _mysql()
|
|||||||
;;
|
;;
|
||||||
--default-character-set|-P|--port|--set-variable|\
|
--default-character-set|-P|--port|--set-variable|\
|
||||||
--ssl-ca|--ssl-cert|--ssl-cipher|--ssl-key|\
|
--ssl-ca|--ssl-cert|--ssl-cipher|--ssl-key|\
|
||||||
--connect_timeout|max_allowed_packet|--prompt|\
|
--connect_timeout|--max_allowed_packet|--prompt|\
|
||||||
--net_buffer_length|--select_limit|--max_join_size|\
|
--net_buffer_length|--select_limit|--max_join_size|\
|
||||||
--server-arg|--debug|--delimiter|--execute|-e|--pager|\
|
--server-arg|--debug|--delimiter|--execute|-e|--pager|\
|
||||||
--password|-p)
|
--password|-p)
|
||||||
@ -58,11 +58,27 @@ _mysql()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
local help=$(_parse_help "$1"|sed -e '/--password/s/$/=/')
|
case $cur in
|
||||||
help+=" --skip-comment --skip-ssl"
|
--*)
|
||||||
|
# TODO: fix _parse_help
|
||||||
|
local help=$(_parse_help "$1"|sed -e '/--password/s/$/=/' -e 's/[.)]*$//')
|
||||||
|
help+=" --skip-comment --skip-ssl"
|
||||||
|
|
||||||
COMPREPLY=( $( compgen -W "$help" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$help" -- "$cur" ) )
|
||||||
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
# only complete long options
|
||||||
|
-)
|
||||||
|
compopt -o nospace
|
||||||
|
COMPREPLY=( -- )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
COMPREPLY=( $( compgen -W "$(mysqlshow 2>/dev/null|sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" \
|
||||||
|
-- "$cur" ) )
|
||||||
} &&
|
} &&
|
||||||
complete -F _mysql mysql
|
complete -F _mysql mysql
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user