summary refs log tree commit diff
path: root/Completion/Debian/Command/_update-alternatives
blob: eaeb300b84339a0212ff4545797996a8c96bff06 (plain) (blame)
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
59
60
#compdef update-alternatives

local curcontext="$curcontext" context state line expl ret alterdir
typeset -A opt_args

if [[ -d /var/lib/dpkg/alternatives ]];then
    alterdir=/var/lib/dpkg/alternatives
elif [[ -d /var/lib/rpm/alternatives/ ]];then
    alterdir=/var/lib/rpm/alternatives
fi

_arguments -C '--verbose' \
           '--quiet' \
           '--test' \
           '--help' \
           '--version' \
           '--altdir:altdir:_files -/' \
           '--admindir:admindir:_files -/' \
    '--install:*::alt:= ->install' \
    '--remove:*::alt:= ->remove' \
    '--auto:name:_files -W $alterdir' \
    '--display:name:_files -W $alterdir' \
    '--config:name:_files -W $alterdir' && return 0

while true; do
case "$state" in
	islave)
        _call_function ret _update_alternatives_$state && return ret
	state=
	_arguments -C '1:link:_files' \
                   '2:name:_files -W $alterdir' \
                   '3:path:_files' \
                   '--slave:*::more:= ->islave' && return 0
        [[ -z $state ]] && return 1
	;;

	install)
        _call_function ret _update_alternatives_$state && return ret
	_arguments -C '1:link:_files' \
                   '2:name:_files -W $alterdir' \
                   '3:path:_files' \
                   '4:priority:' \
                   '--slave:*::slave:= ->islave' && return 0
        [[ -z $state ]] && return 1
	;;

	remove)
        _call_function ret _update_alternatives_$state && return ret
	_arguments \
                   '1:name:_files -W $alterdir' \
                   '2:path:_files' && return 0
        return 1
	;;

	*)
	return 1
	;;

esac
done