summaryrefslogtreecommitdiff
path: root/completions/ifup
blob: db8de8e06b4f6d57f570323ec44800cf2ef35a6e (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 -eq 1 ]]; then
        _configured_interfaces
        COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") )
    fi
} &&
complete -F _ifupdown ifup ifdown ifquery ifstatus

# ex: filetype=sh