udevadm revision 9d7d42bc406a2ac04639674281ce3ff6beeda790
16389N/A# udevadm(8) completion -*- shell-script -*-
16389N/A#
16389N/A# This file is part of systemd.
16139N/A#
16139N/A# Copyright 2010 Ran Benita
16139N/A#
16139N/A# systemd is free software; you can redistribute it and/or modify it
16139N/A# under the terms of the GNU Lesser General Public License as published by
16139N/A# the Free Software Foundation; either version 2.1 of the License, or
16139N/A# (at your option) any later version.
16139N/A#
16139N/A# systemd is distributed in the hope that it will be useful, but
16139N/A# WITHOUT ANY WARRANTY; without even the implied warranty of
16139N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16139N/A# General Public License for more details.
16139N/A#
16139N/A# You should have received a copy of the GNU Lesser General Public License
16139N/A# along with systemd; If not, see <http://www.gnu.org/licenses/>.
16139N/A
16139N/A__contains_word () {
16139N/A local word=$1; shift
16139N/A for w in $*; do [[ $w = $word ]] && return 0; done
16139N/A return 1
16139N/A}
16139N/A
16139N/A__get_all_sysdevs() {
16139N/A local -a devs=(/sys/bus/*/devices/*/ /sys/class/*/*/)
16139N/A printf '%s\n' "${devs[@]%/}"
16139N/A}
16139N/A
16139N/A_udevadm() {
16139N/A local i verb comps
16139N/A local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
16139N/A local OPTS='-h --help --version --debug'
16139N/A
16139N/A local -A VERBS=(
16139N/A [INFO]='info'
16139N/A [TRIGGER]='trigger'
16139N/A [SETTLE]='settle'
16139N/A [CONTROL]='control'
16139N/A [MONITOR]='monitor'
16139N/A [HWDB]='hwdb'
16139N/A [TESTBUILTIN]='test-builtin'
16139N/A [TEST]='test'
16139N/A )
16139N/A
16139N/A for ((i=0; $i <= $COMP_CWORD; i++)); do
16139N/A if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
16139N/A ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
16139N/A verb=${COMP_WORDS[i]}
16139N/A break
16139N/A fi
16139N/A done
16139N/A
16139N/A if [[ -z $verb && $cur = -* ]]; then
16139N/A COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
16139N/A return 0
16139N/A fi
16139N/A
16139N/A if [[ -z $verb ]]; then
16139N/A comps=${VERBS[*]}
16139N/A
16139N/A elif __contains_word "$verb" ${VERBS[INFO]}; then
16139N/A if [[ $cur = -* ]]; then
16139N/A comps='--help --query= --path= --name= --root --attribute-walk --export-db --cleanup-db'
16139N/A else
16139N/A comps=$( __get_all_sysdevs )
16139N/A fi
16139N/A
16139N/A elif __contains_word "$verb" ${VERBS[TRIGGER]}; then
16139N/A comps='--help --verbose --dry-run --type= --action= --subsystem-match=
16139N/A --subsystem-nomatch= --attr-match= --attr-nomatch= --property-match=
16139N/A --tag-match= --sysname-match= --parent-match='
16139N/A
16139N/A elif __contains_word "$verb" ${VERBS[SETTLE]}; then
16139N/A comps='--help --timeout= --seq-start= --seq-end= --exit-if-exists= --quiet'
16139N/A
16139N/A elif __contains_word "$verb" ${VERBS[CONTROL]}; then
16139N/A comps='--help --exit --log-priority= --stop-exec-queue --start-exec-queue
16139N/A --reload --property= --children-max= --timeout='
16139N/A
16139N/A elif __contains_word "$verb" ${VERBS[MONITOR]}; then
16139N/A comps='--help --kernel --udev --property --subsystem-match= --tag-match='
16139N/A
16139N/A elif __contains_word "$verb" ${VERBS[HWDB]}; then
16139N/A comps='--help --update --test='
16139N/A
16139N/A elif __contains_word "$verb" ${VERBS[TEST]}; then
16139N/A if [[ $cur = -* ]]; then
16139N/A comps='--help --action='
16139N/A else
16139N/A comps=$( __get_all_sysdevs )
16139N/A fi
16139N/A
16139N/A elif __contains_word "$verb" ${VERBS[TESTBUILTIN]}; then
16139N/A comps='blkid btrfs hwdb input_id keyboard kmod net_id path_id usb_id uaccess'
16139N/A fi
16139N/A
16139N/A COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
16139N/A return 0
16139N/A}
16139N/A
16139N/Acomplete -F _udevadm udevadm
16139N/A