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/>.
21 local w word=$1; shift
23 [[ $w = "$word" ]] && return
28 local -a devs=(/sys/bus/*/devices/*/ /sys/class/*/*/)
29 printf '%s\n' "${devs[@]%/}"
34 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
35 local OPTS='-h --help --version --debug'
44 [TESTBUILTIN]='test-builtin'
48 for ((i=0; $i <= $COMP_CWORD; i++)); do
49 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
50 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
56 if [[ -z $verb && $cur = -* ]]; then
57 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
61 if [[ -z $verb ]]; then
64 elif __contains_word "$verb" ${VERBS[INFO]}; then
65 if [[ $cur = -* ]]; then
66 comps='--help --query= --path= --name= --root --attribute-walk --export-db --cleanup-db'
68 comps=$( __get_all_sysdevs )
71 elif __contains_word "$verb" ${VERBS[TRIGGER]}; then
72 comps='--help --verbose --dry-run --type= --action= --subsystem-match=
73 --subsystem-nomatch= --attr-match= --attr-nomatch= --property-match=
74 --tag-match= --sysname-match= --parent-match='
76 elif __contains_word "$verb" ${VERBS[SETTLE]}; then
77 comps='--help --timeout= --seq-start= --seq-end= --exit-if-exists= --quiet'
79 elif __contains_word "$verb" ${VERBS[CONTROL]}; then
80 comps='--help --exit --log-priority= --stop-exec-queue --start-exec-queue
81 --reload --property= --children-max= --timeout='
83 elif __contains_word "$verb" ${VERBS[MONITOR]}; then
84 comps='--help --kernel --udev --property --subsystem-match= --tag-match='
86 elif __contains_word "$verb" ${VERBS[HWDB]}; then
87 comps='--help --update --test='
89 elif __contains_word "$verb" ${VERBS[TEST]}; then
90 if [[ $cur = -* ]]; then
91 comps='--help --action='
93 comps=$( __get_all_sysdevs )
96 elif __contains_word "$verb" ${VERBS[TESTBUILTIN]}; then
97 comps='blkid btrfs hwdb input_id keyboard kmod net_id path_id usb_id uaccess'
100 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
104 complete -F _udevadm udevadm