| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2004 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.6 2004/12/29 10:26:33 ka0ttic Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/bash-completion.eclass,v 1.7 2004/12/30 00:18:25 ka0ttic Exp $ |
| 4 | # |
4 | # |
| 5 | # Simple eclass that provides an interface for installing |
5 | # Simple eclass that provides an interface for installing |
| 6 | # contributed (ie not included in bash-completion proper) |
6 | # contributed (ie not included in bash-completion proper) |
| 7 | # bash-completion scripts. |
7 | # bash-completion scripts. |
| 8 | # |
8 | # |
| … | |
… | |
| 17 | IUSE="${IUSE} bash-completion" |
17 | IUSE="${IUSE} bash-completion" |
| 18 | |
18 | |
| 19 | #RDEPEND="${RDEPEND} |
19 | #RDEPEND="${RDEPEND} |
| 20 | # bash-completion? ( app-shells/bash-completion-config )" |
20 | # bash-completion? ( app-shells/bash-completion-config )" |
| 21 | |
21 | |
| 22 | ##### VARIABLES ##### |
|
|
| 23 | [[ -z "${BASH_COMPLETION_NAME}" ]] && BASH_COMPLETION_NAME="${PN}" |
|
|
| 24 | |
|
|
| 25 | # dobashcompletion <file> <new file> |
22 | # dobashcompletion <file> <new file> |
| 26 | # First arg, <file>, is required and is the location of the bash-completion |
23 | # First arg, <file>, is required and is the location of the bash-completion |
| 27 | # script to install. Second arg, <new file>, is optional and specifies an |
24 | # script to install. Second arg, <new file>, is optional and specifies an |
| 28 | # alternate filename to install as. |
25 | # alternate filename to install as. |
| 29 | |
26 | |
| 30 | dobashcompletion() { |
27 | dobashcompletion() { |
| 31 | [[ -z "$1" ]] && die "usage: dobashcompletion <file> <new file>" |
28 | [[ -z "$1" ]] && die "usage: dobashcompletion <file> <new file>" |
| 32 | [[ -n "$2" ]] && export BASH_COMPLETION_NAME="$2" |
29 | [[ -z "${BASH_COMPLETION_NAME}" ]] && BASH_COMPLETION_NAME="${2:-${PN}}" |
|
|
30 | |
| 33 | if useq bash-completion ; then |
31 | if useq bash-completion ; then |
| 34 | insinto /usr/share/bash-completion |
32 | insinto /usr/share/bash-completion |
| 35 | newins "$1" "${BASH_COMPLETION_NAME}" || die "Failed to install $1" |
33 | newins "$1" "${BASH_COMPLETION_NAME}" || die "Failed to install $1" |
| 36 | fi |
34 | fi |
| 37 | } |
35 | } |