[Bash-completion-devel] bash completion for gnokii(1)
Igor Murzov
e-mail at date.by
Sat Oct 13 13:57:58 UTC 2012
The script looks fine in general, but I have to make some remarks about it.
* There are some minor cosmetic fixes could be done. For example
${words[$((cword-2))]} could be replaced with ${words[cword-2]}.
* The bigger problem is that you are seems to forgot to suppress error
messages of external utils like grep.
* Handling options with "no argument" looks suspicious:
------------------------------------------
# no argument
--getdisplaystatus|--displayoutput)
return 0
;;
------------------------------------------
if some option really doesn't have arguments, then you shouldn't
look at it in "case $prev in ..." -- no argument, no completion --
otherwise you will break completion of $cur word.
But if those options does have arguments, you should change the
comment to "argument required, but no completion available" to
be clear.
* Multilevel arguments should be handled starting from the deepest
ones. So the code should look like this:
------------------------------------------
# handle $pprev
if [[ $((cword-2)) -ge 1 && ${words[cword-2]} =~ --*]]; then
case ${words[cword-2]} in
...
esac
fi
# handle $prev
case $prev in
...
esac
# handle $cur
...
COMPREPLY=( $( compgen -W "$all_cmd" -- "$cur" ) )
------------------------------------------
-- Igor
On Sun, 7 Oct 2012 17:34:18 +0200
Raphaël <raphael.droz at gmail.com> wrote:
> hi,
>
> AFAIR the policy of bash-completion is to have completions maintained
> upstream if it's possible.
>
> A bash completion for gnokii, which probably needs a review, is waiting
> here [1] for some time.
> While not absolutely complete it's already quite handy and compatible
> with bash-completion 2.0.
>
>
>
> enjoy
>
>
> [1] https://gitorious.org/drzraf/bash-completion/blobs/master/completions/gnokii
> (attached too)
>
>
> CC: bash-completion people in case they find something wrong with it
More information about the Bash-completion-devel
mailing list