completion: Invoke the command being completed

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>
This commit is contained in:
Philip Withnall
2024-04-17 15:08:43 +01:00
parent 869ef92858
commit cc22637856
5 changed files with 24 additions and 14 deletions

View File

@@ -8,12 +8,15 @@
__gdbus() {
local gdbus_binary
gdbus_binary="$1"
local IFS=$'\n'
local cur
cur="$(_get_cword :)"
local suggestions
suggestions="$(gdbus complete "${COMP_LINE}" "${COMP_POINT}")"
suggestions="$("$gdbus_binary" complete "${COMP_LINE}" "${COMP_POINT}")"
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$suggestions" -- "$cur"))