O compgen
builtin tem um argumento -X
para esse propósito:
-X filterpat filterpat is a pattern as used for filename expansion. It is applied to the list of possible completions generated by the preceding options and arguments, and each completion matching filterpat is removed from the list. A leading ! in filterpat negates the pattern; in this case, any completion not matching filterpat is removed.
Então você provavelmente poderia fazer algo como:
_avail_kernel_builds() {
case $COMP_CWORD in
1) COMPREPLY=( $(cd /secure/kernel_builds; compgen -d -X "source") ) ;;
esac
}
Então compgen -d
diz "listar as pastas no diretório atual", e -X "source"
diz "... mas filtra qualquer coisa chamada" fonte ".