1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 # This eclass has been superseded by bash-completion-r1 eclass.
7 # Please modify your ebuilds to use that one instead.
9 # @ECLASS: bash-completion.eclass
11 # shell-tools@gentoo.org.
13 # Original author: Aaron Walker <ka0ttic@gentoo.org>
14 # @BLURB: An Interface for installing contributed bash-completion scripts
16 # Simple eclass that provides an interface for installing
17 # contributed (ie not included in bash-completion proper)
18 # bash-completion scripts.
20 # Note: this eclass has been deprecated in favor of bash-completion-r1. Please
21 # use that one instead.
23 # @ECLASS-VARIABLE: BASHCOMPLETION_NAME
25 # Install the completion script with this name (see also dobashcompletion)
27 # @ECLASS-VARIABLE: BASHCOMPFILES
29 # Space delimited list of files to install if dobashcompletion is called without
34 EXPORT_FUNCTIONS pkg_postinst
36 IUSE="bash-completion"
38 # Allow eclass to be inherited by eselect without a circular dependency
39 if [[ ${CATEGORY}/${PN} != app-admin/eselect ]]; then
40 RDEPEND="bash-completion? ( app-admin/eselect )"
42 PDEPEND="bash-completion? ( app-shells/bash-completion )"
44 # @FUNCTION: dobashcompletion
45 # @USAGE: [file] [new_file]
47 # The first argument is the location of the bash-completion script to install,
48 # and is required if BASHCOMPFILES is not set. The second argument is the name
49 # the script will be installed as. If BASHCOMPLETION_NAME is set, it overrides
50 # the second argument. If no second argument is given and BASHCOMPLETION_NAME
51 # is not set, it will default to ${PN}.
55 eqawarn "bash-completion.eclass has been deprecated."
56 eqawarn "Please update your ebuilds to use bash-completion-r1 instead."
58 if [[ -z ${1} && -z ${BASHCOMPFILES} ]]; then
59 die "Usage: dobashcompletion [file] [new file]"
62 if use bash-completion; then
63 insinto /usr/share/bash-completion
64 if [[ -n ${1} ]]; then
65 [[ -z ${BASHCOMPLETION_NAME} ]] && BASHCOMPLETION_NAME="${2:-${PN}}"
66 newins "${1}" "${BASHCOMPLETION_NAME}" || die "Failed to install ${1}"
68 set -- ${BASHCOMPFILES}
70 if [[ -e ${f} ]]; then
71 doins "${f}" || die "Failed to install ${f}"
78 # @FUNCTION: bash-completion_pkg_postinst
80 # The bash-completion pkg_postinst function, which is exported
81 bash-completion_pkg_postinst() {
84 if use bash-completion ; then
85 elog "The following bash-completion scripts have been installed:"
86 if [[ -n ${BASHCOMPLETION_NAME} ]]; then
87 elog " ${BASHCOMPLETION_NAME}"
89 set -- ${BASHCOMPFILES}
91 elog " $(basename ${f})"
95 elog "To enable command-line completion on a per-user basis run:"
96 elog " eselect bashcomp enable <script>"
98 elog "To enable command-line completion system-wide run:"
99 elog " eselect bashcomp enable --global <script>"