File: gdbus

package info (click to toggle)
glib2.0 2.86.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 67,020 kB
  • sloc: ansic: 544,698; python: 9,702; sh: 1,612; xml: 1,482; perl: 1,222; cpp: 535; makefile: 308; javascript: 11
file content (58 lines) | stat: -rw-r--r-- 1,809 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
# Copyright 2010 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# licence, or (at your option) any later version.
#
# This is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, see <http://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: LGPL-2.1-or-later

# 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