I did this. Then the completion candidate is displayed like this,
$ foo() { COMPREPLY=($(compgen -W "abc def ghi" -- "$2")); }
$ complete -E -F foo
$ (two times tab key)
abc def ghi
$
And I thought that abc would be complemented by the following:
$ ab (presstab key)
However, commands that start with ab actually appear as completion candidates.
$ ab (two times tab key)
ab abrt-action-save-package-data
abrt-action-analyze-backtrace abrt-action-trim-files
abrt-action-analyze-c abrt-auto-reporting
In man bash, indeed, the -E option indicates that the remaining options and behavior apply to "empty" command completion (completion attempted on blank lines).
It says that only when it is "empty" is as described, but there is no use for the -E option. Also, it seems that there is no way to do completion other than command name completion when the command is not yet recognized like "ab tab twice" above.
Is this something we can't do anymore, or is there something overlooked?