/[gentoo-x86]/eclass/bash-completion.eclass
Gentoo

Contents of /eclass/bash-completion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (show annotations) (download)
Wed Apr 7 04:20:46 2010 UTC (4 years, 3 months ago) by darkside
Branch: MAIN
Changes since 1.23: +8 -8 lines
Due to portage's environment filtering, variables that start with BASH_ cannot be used. As such, s/BASH_COMPLETION_NAME/BASHCOMPLETION_NAME/g for bug 312671

1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v 1.23 2010/01/02 00:07:46 ulm Exp $
4
5 # @ECLASS: bash-completion.eclass
6 # @MAINTAINER:
7 # shell-tools@gentoo.org.
8 #
9 # Original author: Aaron Walker <ka0ttic@gentoo.org>
10 # @BLURB: An Interface for installing contributed bash-completion scripts
11 # @DESCRIPTION:
12 # Simple eclass that provides an interface for installing
13 # contributed (ie not included in bash-completion proper)
14 # bash-completion scripts.
15
16 # @ECLASS-VARIABLE: BASHCOMPLETION_NAME
17 # @DESCRIPTION:
18 # Install the completion script with this name (see also dobashcompletion)
19
20 EXPORT_FUNCTIONS pkg_postinst
21
22 IUSE="bash-completion"
23
24 # Allow eclass to be inherited by eselect without a circular dependency
25 if [[ ${CATEGORY}/${PN} != app-admin/eselect ]]; then
26 RDEPEND="bash-completion? ( app-admin/eselect )"
27 fi
28 PDEPEND="bash-completion? ( app-shells/bash-completion )"
29
30 # @FUNCTION: dobashcompletion
31 # @USAGE: < file > [ new_file ]
32 # @DESCRIPTION:
33 # First arg, <file>, is required and is the location of the bash-completion
34 # script to install. If the variable BASHCOMPLETION_NAME is set in the
35 # ebuild, dobashcompletion will install <file> as
36 # /usr/share/bash-completion/$BASHCOMPLETION_NAME. If it is not set,
37 # dobashcompletion will check if a second arg [new_file] was passed, installing as
38 # the specified name. Failing both these checks, dobashcompletion will
39 # install the file as /usr/share/bash-completion/${PN}.
40 dobashcompletion() {
41 [[ -z "$1" ]] && die "usage: dobashcompletion <file> <new file>"
42 [[ -z "${BASHCOMPLETION_NAME}" ]] && BASHCOMPLETION_NAME="${2:-${PN}}"
43
44 if use bash-completion ; then
45 insinto /usr/share/bash-completion
46 newins "$1" "${BASHCOMPLETION_NAME}" || die "Failed to install $1"
47 fi
48 }
49
50 # @FUNCTION: bash-completion_pkg_postinst
51 # @DESCRIPTION:
52 # The bash-completion pkg_postinst function, which is exported
53 bash-completion_pkg_postinst() {
54 if use bash-completion ; then
55 elog "In the case that you haven't yet enabled command-line completion"
56 elog "for ${PN}, you can run:"
57 elog
58 elog " eselect bashcomp enable ${BASHCOMPLETION_NAME:-${PN}}"
59 elog
60 elog "to install locally, or"
61 elog
62 elog " eselect bashcomp enable --global ${BASHCOMPLETION_NAME:-${PN}}"
63 elog
64 elog "to install system-wide."
65 fi
66 }

  ViewVC Help
Powered by ViewVC 1.1.20