diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:19 +0000 |
commit | 6c09f2a45c5541e9c207d14fc7aa21a4a0066bde (patch) | |
tree | 0221189d367bf661f6f9493c4f17a03f0dd4b7d2 /completions/mysql | |
parent | Releasing progress-linux version 1:2.11-8~progress7.99u1. (diff) | |
download | bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.tar.xz bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.zip |
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/mysql')
-rw-r--r-- | completions/mysql | 80 |
1 files changed, 45 insertions, 35 deletions
diff --git a/completions/mysql b/completions/mysql index 9363133..4ba049f 100644 --- a/completions/mysql +++ b/completions/mysql @@ -1,83 +1,94 @@ # mysql(1) completion -*- shell-script -*- -_mysql_character_sets() +# @since 2.12 +_comp_xfunc_mysql_compgen_character_sets() { - local IFS=$' \t\n' reset=$(shopt -p failglob) - shopt -u failglob - local -a charsets=(/usr/share/m{ariadb,ysql}/charsets/*.xml) - $reset + local -a charsets + _comp_expand_glob charsets '/usr/share/m{ariadb,ysql}/charsets/!(Index).xml' + charsets+=(utf8) charsets=("${charsets[@]##*/}") - charsets=("${charsets[@]%%?(Index|\*).xml}" utf8) - COMPREPLY+=($(compgen -W '${charsets[@]}' -- "$cur")) + charsets=("${charsets[@]%.xml}") + _comp_compgen -U charsets -- -W '"${charsets[@]}"' -X '' } -_mysql() +# @deprecated 2.12 +_mysql_character_sets() { - local cur prev words cword split - _init_completion -s || return + _comp_compgen -ax mysql character_sets "$@" +} +_comp_cmd_mysql() +{ + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return + + # Prefer `mysqlshow` in the same dir as the command + local pathcmd + pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH + + local noargopts='!(-*|*[uDhSPeI]*)' + # shellcheck disable=SC2254 case $prev in - --user | -!(-*)u) - COMPREPLY=($(compgen -u -- "$cur")) + --user | -${noargopts}u) + _comp_compgen -- -u return ;; - --database | -!(-*)D) - COMPREPLY=($(compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur")) + --database | -${noargopts}D) + _comp_compgen_split -- "$(mysqlshow 2>/dev/null | + command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" return ;; - --host | -!(-*)h) - _known_hosts_real -- "$cur" + --host | -${noargopts}h) + _comp_compgen_known_hosts -- "$cur" return ;; --default-character-set) - _mysql_character_sets + _comp_xfunc_mysql_compgen_character_sets return ;; --character-sets-dir | --ssl-capath) - _filedir -d + _comp_compgen_filedir -d return ;; - --socket | -!(-*)S) - _filedir sock + --socket | -${noargopts}S) + _comp_compgen_filedir sock return ;; --protocol) - COMPREPLY=($(compgen -W 'tcp socket pipe memory' -- "$cur")) + _comp_compgen -- -W 'tcp socket pipe memory' return ;; --defaults-file | --defaults-extra-file | --tee) - _filedir + _comp_compgen_filedir return ;; --ssl-ca | --ssl-cert) - _filedir '@(pem|cer|c?(e)rt)' + _comp_compgen_filedir '@(pem|cer|c?(e)rt)' return ;; --ssl-key) - _filedir '@(pem|key)' + _comp_compgen_filedir '@(pem|key)' return ;; --port | --set-variable | --ssl-cipher | --connect_timeout | \ --max_allowed_packet | --prompt | --net_buffer_length | --select_limit | \ --max_join_size | --server-arg | --debug | --delimiter | --execute | --pager | \ - -!(-*)[Pe]) + -${noargopts}[Pe]) return ;; - --help | --version | -!(-*)[?IV]) + --help | --version | -${noargopts}[?IV]) return ;; esac - $split && return + [[ $was_split ]] && return case $cur in --*) - local help=$(_parse_help "$1") - help+=" --skip-comments --skip-ssl" - - COMPREPLY=($(compgen -W "$help" -- "$cur")) + _comp_compgen_help + _comp_compgen -a -- -W '--skip-comments --skip-ssl' [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return ;; @@ -90,10 +101,9 @@ _mysql() ;; esac - COMPREPLY=($(compgen -W \ - "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" \ - -- "$cur")) + _comp_compgen_split -- "$(mysqlshow 2>/dev/null | + command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" } && - complete -F _mysql mysql + complete -F _comp_cmd_mysql mysql # ex: filetype=sh |