[Bash-completion-devel] [SCM] bash-completion branch, master, updated. 1.3-359-g8a63dc2

Ville Skyttä ville.skytta at iki.fi
Sun Jun 12 10:25:58 UTC 2011


On 06/11/2011 11:30 PM, David Paleino wrote:
> The following commit has been merged in the master branch:
> commit 8a63dc2589e17dca0e78baa83878f1fa0638199b
> Author: Raphaël Droz <raphael.droz+floss at gmail.com>
> Date:   Sat Jun 11 22:29:26 2011 +0200
> 
>     mysql: new completion.

Basic test case and completions/Makefile.am entry missing.

> diff --git a/completions/mysql b/completions/mysql
> new file mode 100644
> index 0000000..dbf81a0
> --- /dev/null
> +++ b/completions/mysql
> @@ -0,0 +1,76 @@
> +# mysql(1) completion
> +
> +have mysql || return
> +
> +_mysql()
> +{
> +    local cur prev split=false
> +
> +    COMPREPLY=()
> +    _get_comp_words_by_ref cur prev

Why not use _init_completion?

> +
> +    _split_longopt && split=true
> +
> +    case $prev in
> +        -u|--user)
> +            COMPREPLY=( $( compgen -u -- "$cur" ) )
> +            return 0
> +            ;;
> +        -D|--database)
> +            COMPREPLY=( $( compgen -W "$(mysqlshow|sed -ne '2d' -e 's/^|.\([^|]\+\)|.*/\1/p')" -- "$cur" ) )

The sed looks nonportable if the "\+" is meant to be "one or more";
"\{1,\}" would be portable.

Also, my earlier comment about mysqlshow possibly exiting with an error
has not been addressed:

http://lists.alioth.debian.org/pipermail/bash-completion-devel/2011-May/003667.html



More information about the Bash-completion-devel mailing list