summaryrefslogtreecommitdiffstats
path: root/completions/ifup
blob: 5b35bfb246c5c2c81b048e5df55124f4d7bce0ee (plain)
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
# Red Hat & Debian GNU/Linux if{up,down} completion        -*- shell-script -*-

_userland GNU || return 1

_ifupdown()
{
    local cur prev words cword
    _init_completion || return

    case $prev in
        --help | --version | --allow | --exclude | --option | -!(-*)[hVXo])
            return
            ;;
        --interfaces | -!(-*)i)
            _filedir
            return
            ;;
        --state-dir)
            _filedir -d
            return
            ;;
    esac

    if [[ $cur == -* ]]; then
        COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
        return
    fi

    local args
    _count_args "" "@(--allow|-i|--interfaces|--state-dir|-X|--exclude|-o)"

    if ((args == 1)); then
        _configured_interfaces
        COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
    fi
} &&
    complete -F _ifupdown ifup ifdown ifquery ifstatus

# ex: filetype=sh