- handle the case whereby we're sourced from a shell function

This commit is contained in:
ianmacd 2003-05-26 16:17:05 +00:00
parent 97fcd8097d
commit cfd4576b9b

View File

@ -1,6 +1,6 @@
# bash_completion - some programmable completion functions for bash 2.05b
#
# $Id: bash_completion,v 1.569 2003/05/26 06:50:45 ianmacd Exp $
# $Id: bash_completion,v 1.570 2003/05/26 18:17:05 ianmacd Exp $
#
# Copyright (C) Ian Macdonald <ian@caliban.org>
#
@ -24,8 +24,19 @@
# Alter the following to reflect the location of this file
#
declare -r BASH_COMPLETION=${BASH_COMPLETION:-/etc/bash_completion} 2>/dev/null
declare -r BASH_COMPLETION_DIR=${BASH_COMPLETION_DIR:=/etc/bash_completion.d} 2>/dev/null
if [ -n "$FUNCNAME" ]; then
# we're being sourced from within a function, so we can't use
# 'declare', as this will create local variables within a function
BASH_COMPLETION=${BASH_COMPLETION:-/etc/bash_completion} 2>/dev/null
BASH_COMPLETION_DIR=${BASH_COMPLETION_DIR:=/etc/bash_completion.d} \
2>/dev/null
else
declare -r BASH_COMPLETION=${BASH_COMPLETION:-/etc/bash_completion} \
2>/dev/null
declare -r \
BASH_COMPLETION_DIR=${BASH_COMPLETION_DIR:=/etc/bash_completion.d} \
2>/dev/null
fi
# Set a couple of useful vars
#