1#compdef update-alternatives 2 3local curcontext="$curcontext" context state line alterdir 4 5if [[ -d /var/lib/dpkg/alternatives ]]; then 6 alterdir=/var/lib/dpkg/alternatives 7elif [[ -d /var/lib/rpm/alternatives/ ]]; then 8 alterdir=/var/lib/rpm/alternatives 9fi 10 11_arguments -C \ 12 '--verbose' \ 13 '--quiet' \ 14 '--test' \ 15 '--help' \ 16 '--version' \ 17 '--altdir:altdir:_files -/' \ 18 '--admindir:admindir:_files -/' \ 19 '--log:log file:_files -/' \ 20 '--force' \ 21 '--skip-auto' \ 22 '--install:*::alt:= ->install' \ 23 '--remove:*::alt:= ->remove' \ 24 '--remove-all:name:_files -W "$alterdir"' \ 25 '--auto:name:_files -W "$alterdir"' \ 26 '--display:name:_files -W "$alterdir"' \ 27 '--query:name:_files -W "$alterdir"' \ 28 '--list:name:_files -W "$alterdir"' \ 29 '--get-selections' \ 30 '--set-selections' \ 31 '--config:name:_files -W "$alterdir"' \ 32 '--set:name:_files -W "$alterdir":path:_files -/' \ 33 '--all' && return 34 35while true; do 36 case "$state" in 37 islave) 38 _call_function ret _update_alternatives_$state && return ret 39 state= 40 _arguments -C \ 41 '1:link:_files' \ 42 '2:name:_files -W "$alterdir"' \ 43 '3:path:_files' \ 44 '--slave:*::more:= ->islave' && return 45 [[ -z $state ]] && return 1 46 ;; 47 48 install) 49 _call_function ret _update_alternatives_$state && return ret 50 _arguments -C \ 51 '1:link:_files' \ 52 '2:name:_files -W "$alterdir"' \ 53 '3:path:_files' \ 54 '4:priority:' \ 55 '--slave:*::slave:= ->islave' && return 56 [[ -z $state ]] && return 1 57 ;; 58 59 remove) 60 _call_function ret _update_alternatives_$state && return ret 61 _arguments \ 62 '1:name:_files -W "$alterdir"' \ 63 '2:path:_files' 64 return 65 ;; 66 67 *) return 1 ;; 68 esac 69done 70