summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-shells/bash-completion/files/bash-completion.sh')
-rw-r--r--app-shells/bash-completion/files/bash-completion.sh71
1 files changed, 35 insertions, 36 deletions
diff --git a/app-shells/bash-completion/files/bash-completion.sh b/app-shells/bash-completion/files/bash-completion.sh
index aca4fac00e95..aa84784ff74a 100644
--- a/app-shells/bash-completion/files/bash-completion.sh
+++ b/app-shells/bash-completion/files/bash-completion.sh
@@ -1,39 +1,38 @@
-# Copyright 1999-2004 Gentoo Foundation
+# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
-# $Header: /var/cvsroot/gentoo-x86/app-shells/bash-completion/files/bash-completion.sh,v 1.3 2008/06/15 23:22:32 zlin Exp $
-#
-# START bash completion -- do not remove this line
+# $Header: /var/cvsroot/gentoo-x86/app-shells/bash-completion/files/bash-completion.sh,v 1.4 2009/10/15 13:52:36 darkside Exp $
-# Need interactive bash with complete builtin
-if [ -n "$PS1" -a -n "$BASH_VERSION" -a \
- "`type -t complete 2>/dev/null`" = builtin ]
-then
+# Check for interactive bash and that we haven't already been sourced.
+[ -z "$BASH_VERSION" -o -z "$PS1" -o -n "$BASH_COMPLETION" ] && return
+
+# Check for recent enough version of bash.
+bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}
+if [ $bmajor -eq 2 -a $bminor '>' 04 ] || [ $bmajor -gt 2 ]; then
_load_completions() {
- declare f x loaded_pre=false
- for f; do
- if [[ -f $f ]]; then
- # Prevent loading base twice, initially and via glob
- if $loaded_pre && [[ $f == */base ]]; then
- continue
- fi
+ declare f x loaded_base=false
+ for f; do
+ if [[ -f $f ]]; then
+ # Prevent loading base twice, initially and via glob
+ if $loaded_base && [[ $f == */.bash-completion ]]; then
+ continue
+ fi
- # Some modules, including base, depend on the definitions
- # in .pre. See the ebuild for how this is created.
- if ! $loaded_pre; then
- if [[ ${BASH_COMPLETION-unset} == unset ]]; then
- BASH_COMPLETION=/usr/share/bash-completion/base
- fi
- source /usr/share/bash-completion/.pre
- loaded_pre=true
- fi
+ # Some modules, including base, depend on the definitions
+ # in .pre. See the ebuild for how this is created.
+ if ! $loaded_base; then
+ if [[ ${BASH_COMPLETION-unset} == unset ]]; then
+ BASH_COMPLETION=/usr/share/bash-completion/.bash-completion
+ fi
+ source /usr/share/bash-completion/.bash-completion
+ loaded_base=true
+ fi
- source "$f"
- fi
- done
+ source "$f"
+ fi
+ done
- # Clean up
- $loaded_pre && source /usr/share/bash-completion/.post
- unset -f _load_completions # not designed to be called more than once
+ # Clean up
+ unset -f _load_completions # not designed to be called more than once
}
# 1. Load base, if eselected. This was previously known as
@@ -41,12 +40,12 @@ then
# 2. Load completion modules, maintained via eselect bashcomp --global
# 3. Load user completion modules, maintained via eselect bashcomp
# 4. Load user completion file last, overrides modules at user discretion
+ # This order is subject to change once upstream decides on something.
_load_completions \
- /etc/bash_completion.d/base \
- ~/.bash_completion.d/base \
- /etc/bash_completion.d/* \
- ~/.bash_completion.d/* \
- ~/.bash_completion
+ /usr/share/bash-completion/.bash-completion
+ /etc/bash_completion.d/* \
+ ~/.bash_completion.d/* \
+ ~/.bash_completion
fi
-# END bash completion -- do not remove this line
+unset bash bminor bmajor