Hi,

One of the requirements of the completion autoloading is that there is
a file or symlink in ${completionsdir} for every completed command. For
example, if 'bakefile' completion provides completions for both
bakefile and bakefile_gen, there should be an extra symlink
from bakefile_gen to bakefile.

To make it easy to accommodate this requirements for Gentoo-originating
completions and to fix issues with upstream completions, I would like
to add a new bashcomp_alias() function.

It is to be used like:

  newbashcomp bash_completion bakefile
  bashcomp_alias bakefile bakefile_gen

or:

  bashcomp_alias emerge ebuild revdep-rebuild metagen ...

Please review.

diff -u -B -r1.13 bash-completion-r1.eclass
--- bash-completion-r1.eclass   27 Aug 2014 08:15:27 -0000      1.13
+++ bash-completion-r1.eclass   27 Aug 2014 14:47:01 -0000
@@ -116,3 +116,19 @@
                newins "${@}"
        )
 }
+
+# @FUNCTION: bashcomp_alias
+# @USAGE: <basename> <alias>...
+# @DESCRIPTION:
+# Alias <basename> completion to one or more commands (<alias>es).
+bashcomp_alias() {
+       debug-print-function ${FUNCNAME} "${@}"
+
+       [[ ${#} -lt 2 ]] && die "Usage: ${FUNCNAME} <basename> <alias>..."
+       local base=${1} f
+       shift
+
+       for f; do
+               dosym "${base}" "$(_bash-completion-r1_get_bashcompdir)/${f}"
+       done
+}

-- 
Best regards,
Michał Górny

Attachment: signature.asc
Description: PGP signature

Reply via email to