__load_completion: New function, use in _completion_loader and _xfunc
Effectively makes _xfunc load completion files the same way as _completion_loader, earlier it was more limited.
This commit is contained in:
parent
69cfaed89c
commit
cad3abfc7e
@ -1956,21 +1956,30 @@ _minimal()
|
|||||||
complete -F _minimal ''
|
complete -F _minimal ''
|
||||||
|
|
||||||
|
|
||||||
# set up dynamic completion loading
|
__load_completion()
|
||||||
_completion_loader()
|
|
||||||
{
|
{
|
||||||
# $1=_EmptycmD_ already for empty cmds in bash 4.3, set to it for earlier
|
local cmd="$1" compdir=./completions compfile dir
|
||||||
local cmd="${1:-_EmptycmD_}" compdir=./completions compfile dir
|
|
||||||
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
|
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
|
||||||
|
|
||||||
for dir in ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions $compdir; do
|
for dir in ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions $compdir; do
|
||||||
for compfile in "${cmd##*/}" "${cmd##*/}".bash _"${cmd##*/}"; do
|
for compfile in "${cmd##*/}" "${cmd##*/}".bash _"${cmd##*/}"; do
|
||||||
compfile="$dir/$compfile"
|
compfile="$dir/$compfile"
|
||||||
# Avoid trying to source dirs; https://bugzilla.redhat.com/903540
|
# Avoid trying to source dirs; https://bugzilla.redhat.com/903540
|
||||||
[[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 124
|
[[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 0
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# set up dynamic completion loading
|
||||||
|
_completion_loader()
|
||||||
|
{
|
||||||
|
# $1=_EmptycmD_ already for empty cmds in bash 4.3, set to it for earlier
|
||||||
|
local cmd="${1:-_EmptycmD_}"
|
||||||
|
|
||||||
|
__load_completion "$cmd" && return 124
|
||||||
|
|
||||||
# Need to define *something*, otherwise there will be no completion at all.
|
# Need to define *something*, otherwise there will be no completion at all.
|
||||||
complete -F _minimal -- "$cmd" && return 124
|
complete -F _minimal -- "$cmd" && return 124
|
||||||
} &&
|
} &&
|
||||||
@ -1986,9 +1995,7 @@ _xfunc()
|
|||||||
local srcfile=$1
|
local srcfile=$1
|
||||||
shift
|
shift
|
||||||
declare -F $1 &>/dev/null || {
|
declare -F $1 &>/dev/null || {
|
||||||
local compdir=./completions
|
__load_completion "$srcfile"
|
||||||
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
|
|
||||||
. "$compdir/$srcfile"
|
|
||||||
}
|
}
|
||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user