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
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.