mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
cc22637856
As suggested by Ville Skyttä in https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4012#note_2084405, make sure to invoke the copy of the command which is being completed when asking for completions of a given subcommand. This avoids accidentally invoking any old `gdbus`/`gresource`/etc. binary which is hanging around in another part of `$PATH`. Signed-off-by: Philip Withnall <pwithnall@gnome.org>
42 lines
1.1 KiB
Plaintext
42 lines
1.1 KiB
Plaintext
|
|
# shellcheck shell=bash
|
|
|
|
# Check for bash
|
|
[ -z "$BASH_VERSION" ] && return
|
|
|
|
####################################################################################################
|
|
|
|
|
|
__gdbus() {
|
|
local gdbus_binary
|
|
gdbus_binary="$1"
|
|
|
|
local IFS=$'\n'
|
|
local cur
|
|
cur="$(_get_cword :)"
|
|
|
|
local suggestions
|
|
suggestions="$("$gdbus_binary" complete "${COMP_LINE}" "${COMP_POINT}")"
|
|
# shellcheck disable=SC2207
|
|
COMPREPLY=($(compgen -W "$suggestions" -- "$cur"))
|
|
|
|
# Remove colon-word prefix from COMPREPLY items
|
|
case "$cur" in
|
|
*:*)
|
|
case "$COMP_WORDBREAKS" in
|
|
*:*)
|
|
local colon_word=${cur%"${cur##*:}"}
|
|
local i=${#COMPREPLY[*]}
|
|
while [ $((--i)) -ge 0 ]; do
|
|
COMPREPLY[i]=${COMPREPLY[i]#"$colon_word"}
|
|
done
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
}
|
|
|
|
####################################################################################################
|
|
|
|
complete -o nospace -F __gdbus gdbus
|