# Install real completion
# See also: _comp_install()
# @param $* string  (optional) Arguments to use for completion.  Default is "-F _${BASH_ARGV[0]}"
comp_install() {
    # Do not install when COMP_INSTALL equals 0
    if [ "${COMP_INSTALL:-1}" -ne 0 ]; then
	local comp=${BASH_ARGV[0]##*/}  # ${..##*/}: strip up to and including last slash
	local dir="${BASH_ARGV[0]%/$comp}"  # Extract dir from completion

	_comp_install $comp "$dir" "$*"
    fi
} # comp_install()


# Install real completion
# NOTE: The default function of the original bash_completion is "_$command".
#       A less collision-prone default might be "_comp_$command", e.g.
#       `_comp_ssh' instead of `_ssh' -- FVu, Sat Apr  5 09:21:21 CEST 2008
# @param $1 string comp
# @param $2 string dir
# @param $* string  (optional) Arguments to use for completion.  Default is "-F _${BASH_ARGV[0]}"
_comp_install() {
    local comp=$1
    shift
    local dir="$1"
    shift
        # Don't install completion if 'comp_dir2args()' returns false
    if comp_dir2args "$dir"; then
        eval complete ${*:--F _$comp} $COMP_ARGS ${COMP_WORDS[0]}
    else
        complete -r $comp
    fi
    unset -v COMP_ARGS
} # _comp_install()
