1 # udevadm(8) completion -*- shell-script -*-
3 # This file is part of systemd.
5 # Copyright 2010 Ran Benita
7 # systemd is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # systemd is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 for w in $*; do [[ $w = $word ]] && return 0; done
27 local -a devs=(/sys/bus/*/devices/*/ /sys/class/*/*/)
28 printf '%s\n' "${devs[@]%/}"
33 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
34 local OPTS='-h --help --version --debug'
43 [TESTBUILTIN]='test-builtin'
47 for ((i=0; $i <= $COMP_CWORD; i++)); do
48 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
49 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
55 if [[ -z $verb && $cur = -* ]]; then
56 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
60 if [[ -z $verb ]]; then
63 elif __contains_word "$verb" ${VERBS[INFO]}; then
64 if [[ $cur = -* ]]; then
65 comps='--help --query= --path= --name= --root --attribute-walk --export-db --cleanup-db'
67 comps=$( __get_all_sysdevs )
70 elif __contains_word "$verb" ${VERBS[TRIGGER]}; then
71 comps='--help --verbose --dry-run --type= --action= --subsystem-match=
72 --subsystem-nomatch= --attr-match= --attr-nomatch= --property-match=
73 --tag-match= --sysname-match= --parent-match='
75 elif __contains_word "$verb" ${VERBS[SETTLE]}; then
76 comps='--help --timeout= --seq-start= --seq-end= --exit-if-exists= --quiet'
78 elif __contains_word "$verb" ${VERBS[CONTROL]}; then
79 comps='--help --exit --log-priority= --stop-exec-queue --start-exec-queue
80 --reload --property= --children-max= --timeout='
82 elif __contains_word "$verb" ${VERBS[MONITOR]}; then
83 comps='--help --kernel --udev --property --subsystem-match= --tag-match='
85 elif __contains_word "$verb" ${VERBS[HWDB]}; then
86 comps='--help --update --test='
88 elif __contains_word "$verb" ${VERBS[TEST]}; then
89 if [[ $cur = -* ]]; then
90 comps='--help --action='
92 comps=$( __get_all_sysdevs )
95 elif __contains_word "$verb" ${VERBS[TESTBUILTIN]}; then
96 comps='blkid btrfs firmware hwdb input_id kmod net_id path_id usb_id uaccess'
99 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
103 complete -F _udevadm udevadm