Get rid of $BASH_COMPLETION as well

This commit is contained in:
David Paleino 2011-05-02 19:01:33 +02:00
parent 88f9f46d81
commit 4632248cbb
8 changed files with 14 additions and 21 deletions

View File

@ -1,4 +1,4 @@
SUBDIRS = completions test
SUBDIRS = completions helpers test
pkgdata_DATA = bash_completion

7
README
View File

@ -38,11 +38,6 @@ if [ -f /sw/etc/bash_completion ]; then
. /sw/etc/bash_completion
fi
If you are putting the bash completion source file somewhere other
than /etc/bash_completion, you should ensure that $BASH_COMPLETION is
set to point to it before you source it. Your ~/.bashrc file is a good
place to do this.
TROUBLESHOOTING
---------------
@ -125,7 +120,7 @@ Q. I author/maintain package X and would like to maintain my own
completion code for this package. Where should I put it to be sure
that interactive bash shells will find it and source it?
Put it in the directory pointed to by $BASH_COMPLETION_DIR, which
Put it in the directory pointed to by $BASH_COMPLETION_COMPAT_DIR, which
is defined at the beginning of the main completion script. Any
scripts placed in this directory will be sourced by interactive
bash shells. Usually, this is /etc/bash_completion.d.

View File

@ -39,9 +39,8 @@ fi
# Alter the following to reflect the location of this file.
#
[ -n "$BASH_COMPLETION" ] || BASH_COMPLETION=/usr/share/bash-completion/bash_completion
[ -n "$BASH_COMPLETION_COMPAT_DIR" ] || BASH_COMPLETION_COMPAT_DIR=/etc/bash_completion.d
readonly BASH_COMPLETION BASH_COMPLETION_COMPAT_DIR
readonly BASH_COMPLETION_COMPAT_DIR
# Set a couple of useful vars
#
@ -1752,7 +1751,7 @@ _filedir_xspec()
local IFS=$'\n' xspec
# get first exclusion compspec that matches this command
xspec=$( awk "/^complete[ \t]+.*[ \t]${1##*/}([ \t]|\$)/ { print \$0; exit }" \
"$BASH_COMPLETION" )
"${BASH_SOURCE[0]}" )
# prune to leave nothing but the -X spec
xspec=${xspec#*-X }
xspec=${xspec%% *}
@ -1790,7 +1789,7 @@ _filedir_xspec()
[ ${#toks[@]} -ne 0 ] && compopt -o filenames
COMPREPLY=( "${toks[@]}" )
}
list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' "$BASH_COMPLETION" | \
list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' "${BASH_SOURCE[0]}" | \
# read exclusion compspecs
(
while read line
@ -1822,11 +1821,11 @@ if [[ -d $BASH_COMPLETION_COMPAT_DIR && -r $BASH_COMPLETION_COMPAT_DIR && \
&& -f $i && -r $i ]] && . "$i"
done
fi
if [[ "${BASH_COMPLETION%/*}/completions" != $BASH_COMPLETION_COMPAT_DIR && \
-d "${BASH_COMPLETION%/*}/completions" && -r "${BASH_COMPLETION%/*}/completions" && \
-x "${BASH_COMPLETION%/*}/completions" ]]; then
for i in $(LC_ALL=C command ls "${BASH_COMPLETION%/*}/completions"); do
i="${BASH_COMPLETION%/*}/completions/$i"
if [[ "${BASH_SOURCE[0]%/*}/completions" != $BASH_COMPLETION_COMPAT_DIR && \
-d "${BASH_SOURCE[0]%/*}/completions" && -r "${BASH_SOURCE[0]%/*}/completions" && \
-x "${BASH_SOURCE[0]%/*}/completions" ]]; then
for i in $(LC_ALL=C command ls "${BASH_SOURCE[0]%/*}/completions"); do
i="${BASH_SOURCE[0]%/*}/completions/$i"
[[ ${i##*/} != @($_backup_glob|Makefile*) \
&& -f $i && -r $i ]] && . "$i"
done
@ -1834,7 +1833,7 @@ fi
unset i
# source user completion file
[[ $BASH_COMPLETION != ~/.bash_completion && -r ~/.bash_completion ]] \
[[ ${BASH_SOURCE[0]} != ~/.bash_completion && -r ~/.bash_completion ]] \
&& . ~/.bash_completion
unset -f have
unset UNAME USERLAND have

View File

@ -1,5 +1,5 @@
# Check for interactive bash and that we haven't already been sourced.
[ -z "$BASH_VERSION" -o -z "$PS1" -o -n "$BASH_COMPLETION" ] && return
[ -z "$BASH_VERSION" -o -z "$PS1" -o -n "$BASH_COMPLETION_COMPAT_DIR" ] && return
# Check for recent enough version of bash.
bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}

View File

@ -1,4 +1,3 @@
SUBDIRS = helpers
bashcomp_DATA = abook \
ant \
apache2ctl \

View File

@ -5,7 +5,7 @@ have perl || return
_perlmodules()
{
COMPREPLY=( $( compgen -P "$prefix" -W \
"$( ${1:-perl} ${BASH_COMPLETION%/*}/helpers/perl modules $cur )" \
"$( ${1:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl modules $cur )" \
-- "$cur" ) )
__ltrim_colon_completions "$prefix$cur"
}
@ -13,7 +13,7 @@ _perlmodules()
_perlfunctions()
{
COMPREPLY=( $( compgen -P "$prefix" -W \
"$( ${1:-perl} ${BASH_COMPLETION%/*}/helpers/perl functions $cur )" \
"$( ${1:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl functions $cur )" \
-- "$cur" ) )
}