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

Diff of /eclass/bash-completion.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.24 Revision 1.25
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2010 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v 1.24 2010/04/07 04:20:46 darkside Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v 1.25 2011/03/31 04:13:51 dirtyepic Exp $
4 4
5# @ECLASS: bash-completion.eclass 5# @ECLASS: bash-completion.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# shell-tools@gentoo.org. 7# shell-tools@gentoo.org.
8# 8#
15 15
16# @ECLASS-VARIABLE: BASHCOMPLETION_NAME 16# @ECLASS-VARIABLE: BASHCOMPLETION_NAME
17# @DESCRIPTION: 17# @DESCRIPTION:
18# Install the completion script with this name (see also dobashcompletion) 18# Install the completion script with this name (see also dobashcompletion)
19 19
20# @ECLASS-VARIABLE: BASHCOMPFILES
21# @DESCRIPTION:
22# Space delimited list of files to install if dobashcompletion is called without
23# arguments.
24
20EXPORT_FUNCTIONS pkg_postinst 25EXPORT_FUNCTIONS pkg_postinst
21 26
22IUSE="bash-completion" 27IUSE="bash-completion"
23 28
24# Allow eclass to be inherited by eselect without a circular dependency 29# Allow eclass to be inherited by eselect without a circular dependency
26 RDEPEND="bash-completion? ( app-admin/eselect )" 31 RDEPEND="bash-completion? ( app-admin/eselect )"
27fi 32fi
28PDEPEND="bash-completion? ( app-shells/bash-completion )" 33PDEPEND="bash-completion? ( app-shells/bash-completion )"
29 34
30# @FUNCTION: dobashcompletion 35# @FUNCTION: dobashcompletion
31# @USAGE: < file > [ new_file ] 36# @USAGE: [file] [new_file]
32# @DESCRIPTION: 37# @DESCRIPTION:
33# First arg, <file>, is required and is the location of the bash-completion 38# The first argument is the location of the bash-completion script to install,
34# script to install. If the variable BASHCOMPLETION_NAME is set in the 39# and is required if BASHCOMPFILES is not set. The second argument is the name
35# ebuild, dobashcompletion will install <file> as 40# the script will be installed as. If BASHCOMPLETION_NAME is set, it overrides
36# /usr/share/bash-completion/$BASHCOMPLETION_NAME. If it is not set, 41# the second argument. If no second argument is given and BASHCOMPLETION_NAME
37# dobashcompletion will check if a second arg [new_file] was passed, installing as 42# is not set, it will default to ${PN}.
38# the specified name. Failing both these checks, dobashcompletion will
39# install the file as /usr/share/bash-completion/${PN}.
40dobashcompletion() { 43dobashcompletion() {
41 [[ -z "$1" ]] && die "usage: dobashcompletion <file> <new file>" 44 local f
42 [[ -z "${BASHCOMPLETION_NAME}" ]] && BASHCOMPLETION_NAME="${2:-${PN}}"
43 45
46 if [[ -z ${1} && -z ${BASHCOMPFILES} ]]; then
47 die "Usage: dobashcompletion [file] [new file]"
48 fi
49
44 if use bash-completion ; then 50 if use bash-completion; then
45 insinto /usr/share/bash-completion 51 insinto /usr/share/bash-completion
52 if [[ -n ${1} ]]; then
53 [[ -z ${BASHCOMPLETION_NAME} ]] && BASHCOMPLETION_NAME="${2:-${PN}}"
46 newins "$1" "${BASHCOMPLETION_NAME}" || die "Failed to install $1" 54 newins "${1}" "${BASHCOMPLETION_NAME}" || die "Failed to install ${1}"
55 else
56 set -- ${BASHCOMPFILES}
57 for f in "$@"; do
58 if [[ -e ${f} ]]; then
59 doins "${f}" || die "Failed to install ${f}"
60 fi
61 done
62 fi
47 fi 63 fi
48} 64}
49 65
50# @FUNCTION: bash-completion_pkg_postinst 66# @FUNCTION: bash-completion_pkg_postinst
51# @DESCRIPTION: 67# @DESCRIPTION:
52# The bash-completion pkg_postinst function, which is exported 68# The bash-completion pkg_postinst function, which is exported
53bash-completion_pkg_postinst() { 69bash-completion_pkg_postinst() {
70 local f
71
54 if use bash-completion ; then 72 if use bash-completion ; then
55 elog "In the case that you haven't yet enabled command-line completion" 73 elog "The following bash-completion scripts have been installed:"
56 elog "for ${PN}, you can run:"
57 elog 74 elog
58 elog " eselect bashcomp enable ${BASHCOMPLETION_NAME:-${PN}}" 75 if [[ -n ${BASHCOMPLETION_NAME} ]]; then
76 elog " ${BASHCOMPLETION_NAME}"
77 else
78 set -- ${BASHCOMPFILES}
79 for f in "$@"; do
80 elog " $(basename ${f})"
81 done
82 fi
59 elog 83 elog
60 elog "to install locally, or" 84 elog "To enable command-line completion on a per-user basis run:"
85 elog " eselect bashcomp enable <script>"
61 elog 86 elog
62 elog " eselect bashcomp enable --global ${BASHCOMPLETION_NAME:-${PN}}" 87 elog "To enable command-line completion system-wide run:"
63 elog 88 elog " eselect bashcomp enable --global <script>"
64 elog "to install system-wide."
65 fi 89 fi
66} 90}

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.20