What does `works' mean here,
It means to work like "compgen -c pin", or like
_completion_loader ping; COMP_WORDS=(ping); COMP_CWORD=1;
_known_hosts; declare -p COMPREPLY
or somehow else get possible completion results.
and what are you trying to do with this patch?
I am trying to provide "pcomp_line" buffer which
"gen_compspec_completion" function expect to be. Normally when we just
press <TAB> after "ping ", "pcomp_line" is provided by
"programmable_completions" function (it assign the buffer pointer to
line buffer). This function is called from "attempt_shell_completion"
function according to special logic which it consists (it determines
whether programmable completion is needed).
On the other hand, "compgen" realization function ("compgen_builtin")
just set pcom_line buffer pointer to NULL. Consequently, no programmable
completion is possible in this case, because "pcomp_line" buffer is
necessary. The buffer is parsed in "gen_compspec_completions" in order
to bind variables like "COMP_WORDS", which are used in programmable
completions bash scripts in /usr/share/bash-completion/.
Hope I said clearly. It is second language for me.