chiark / gitweb /
2d425c0aab39e7f5e0f735148ba483c713745237
[elogind.git] / shell-completion / systemd-bash-completion.sh
1 # This file is part of systemd.
2 #
3 # Copyright 2010 Ran Benita
4 #
5 # systemd is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
9 #
10 # systemd is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
17
18 __systemctl() {
19         systemctl --full --no-legend "$@"
20 }
21
22 __contains_word () {
23         local word=$1; shift
24         for w in $*; do [[ $w = $word ]] && return 0; done
25         return 1
26 }
27
28 __filter_units_by_property () {
29         local property=$1 value=$2 ; shift 2
30         local units=("$@")
31         local props
32         IFS=$'\n' read -rd '' -a props < \
33             <(__systemctl show --property "$property" -- "${units[@]}")
34         for ((i=0; $i < ${#units[*]}; i++)); do
35                 if [[ "${props[i]}" = "$property=$value" ]]; then
36                         printf "%s\n" "${units[i]}"
37                 fi
38         done
39 }
40
41 __get_all_units      () { __systemctl list-units --all \
42         | { while read -r a b; do printf "%s\n" "$a"; done; }; }
43 __get_active_units   () { __systemctl list-units       \
44         | { while read -r a b; do printf "%s\n" "$a"; done; }; }
45 __get_inactive_units () { __systemctl list-units --all \
46         | { while read -r a b c d; do [[ $c == "inactive" ]] && printf "%s\n" "$a"; done; }; }
47 __get_failed_units   () { __systemctl list-units       \
48         | { while read -r a b c d; do [[ $c == "failed"   ]] && printf "%s\n" "$a"; done; }; }
49 __get_enabled_units  () { __systemctl list-unit-files  \
50         | { while read -r a b c  ; do [[ $b == "enabled"  ]] && printf "%s\n" "$a"; done; }; }
51 __get_disabled_units () { __systemctl list-unit-files  \
52         | { while read -r a b c  ; do [[ $b == "disabled" ]] && printf "%s\n" "$a"; done; }; }
53 __get_masked_units   () { __systemctl list-unit-files  \
54         | { while read -r a b c  ; do [[ $b == "masked"   ]] && printf "%s\n" "$a"; done; }; }
55
56 _systemctl () {
57         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
58         local i verb comps
59
60         local -A OPTS=(
61                [STANDALONE]='--all -a --defaults --fail --ignore-dependencies --failed --force -f --full --global
62                              --help -h --no-ask-password --no-block --no-legend --no-pager --no-reload --no-wall
63                              --order --require --quiet -q --privileged -P --system --user --version --runtime'
64                       [ARG]='--host -H --kill-mode --kill-who --property -p --signal -s --type -t --root'
65         )
66
67         if __contains_word "$prev" ${OPTS[ARG]}; then
68                 case $prev in
69                         --signal|-s)
70                                 comps=$(compgen -A signal)
71                         ;;
72                         --type|-t)
73                                 comps='automount device mount path service snapshot socket swap target timer'
74                         ;;
75                         --kill-who)
76                                 comps='all control main'
77                         ;;
78                         --kill-mode)
79                                 comps='control-group process'
80                         ;;
81                         --root)
82                                 comps=$(compgen -A directory -- "$cur" )
83                                 compopt -o filenames
84                         ;;
85                         --host|-H)
86                                 comps=$(compgen -A hostname)
87                         ;;
88                         --property|-p)
89                                 comps=''
90                         ;;
91                 esac
92                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
93                 return 0
94         fi
95
96
97         if [[ "$cur" = -* ]]; then
98                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
99                 return 0
100         fi
101
102         local -A VERBS=(
103                 [ALL_UNITS]='is-active is-enabled status show mask preset'
104             [ENABLED_UNITS]='disable reenable'
105            [DISABLED_UNITS]='enable'
106              [FAILED_UNITS]='reset-failed'
107           [STARTABLE_UNITS]='start'
108           [STOPPABLE_UNITS]='stop condstop kill try-restart condrestart'
109          [ISOLATABLE_UNITS]='isolate'
110          [RELOADABLE_UNITS]='reload condreload reload-or-try-restart force-reload'
111         [RESTARTABLE_UNITS]='restart reload-or-restart'
112              [MASKED_UNITS]='unmask'
113                      [JOBS]='cancel'
114                 [SNAPSHOTS]='delete'
115                      [ENVS]='set-environment unset-environment'
116                [STANDALONE]='daemon-reexec daemon-reload default dot dump
117                              emergency exit halt kexec list-jobs list-units
118                              list-unit-files poweroff reboot rescue show-environment'
119                      [NAME]='snapshot load'
120                      [FILE]='link'
121         )
122
123         for ((i=0; $i <= $COMP_CWORD; i++)); do
124                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
125                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
126                         verb=${COMP_WORDS[i]}
127                         break
128                 fi
129         done
130
131         if   [[ -z $verb ]]; then
132                 comps="${VERBS[*]}"
133
134         elif __contains_word "$verb" ${VERBS[ALL_UNITS]}; then
135                 comps=$( __get_all_units )
136
137         elif __contains_word "$verb" ${VERBS[ENABLED_UNITS]}; then
138                 comps=$( __get_enabled_units )
139
140         elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then
141                 comps=$( __get_disabled_units )
142
143         elif __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then
144                 comps=$( __filter_units_by_property CanStart yes \
145                       $( __get_inactive_units \
146                         | while read -r line; do \
147                                 [[ "$line" =~ \.(device|snapshot)$ ]] || printf "%s\n" "$line"; \
148                         done ))
149
150         elif __contains_word "$verb" ${VERBS[RESTARTABLE_UNITS]}; then
151                 comps=$( __filter_units_by_property CanStart yes \
152                       $( __get_all_units \
153                         | while read -r line; do \
154                                 [[ "$line" =~ \.(device|snapshot|socket|timer)$ ]] || printf "%s\n" "$line"; \
155                         done ))
156
157         elif __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then
158                 comps=$( __filter_units_by_property CanStop yes \
159                       $( __get_active_units ) )
160
161         elif __contains_word "$verb" ${VERBS[RELOADABLE_UNITS]}; then
162                 comps=$( __filter_units_by_property CanReload yes \
163                       $( __get_active_units ) )
164
165         elif __contains_word "$verb" ${VERBS[ISOLATABLE_UNITS]}; then
166                 comps=$( __filter_units_by_property AllowIsolate yes \
167                       $( __get_all_units ) )
168
169         elif __contains_word "$verb" ${VERBS[FAILED_UNITS]}; then
170                 comps=$( __get_failed_units )
171
172         elif __contains_word "$verb" ${VERBS[MASKED_UNITS]}; then
173                 comps=$( __get_masked_units )
174
175         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[NAME]}; then
176                 comps=''
177
178         elif __contains_word "$verb" ${VERBS[JOBS]}; then
179                 comps=$( __systemctl list-jobs | { while read -r a b; do printf "%s\n" "$a"; done; } )
180
181         elif __contains_word "$verb" ${VERBS[SNAPSHOTS]}; then
182                 comps=$( __systemctl list-units --type snapshot --full --all \
183                         | { while read -r a b; do printf "%s\n" "$a"; done; } )
184
185         elif __contains_word "$verb" ${VERBS[ENVS]}; then
186                 comps=$( __systemctl show-environment \
187                     | while read -r line; do printf "%s\n" "${line%%=*}=";done )
188                 compopt -o nospace
189
190         elif __contains_word "$verb" ${VERBS[FILE]}; then
191                 comps=$( compgen -A file -- "$cur" )
192                 compopt -o filenames
193         fi
194
195         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
196         return 0
197 }
198 complete -F _systemctl systemctl
199
200 __get_all_sessions () { loginctl list-sessions | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
201 __get_all_users    () { loginctl list-users    | { while read -r a b; do printf "%s\n" "$b"; done; } ; }
202 __get_all_seats    () { loginctl list-seats    | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
203
204 _loginctl () {
205         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
206         local i verb comps
207
208         local -A OPTS=(
209                [STANDALONE]='--all -a --help -h --no-pager --privileged -P --version'
210                       [ARG]='--host -H --kill-who --property -p --signal -s'
211         )
212
213         if __contains_word "$prev" ${OPTS[ARG]}; then
214                 case $prev in
215                         --signal|-s)
216                                 comps=$(compgen -A signal)
217                         ;;
218                         --kill-who)
219                                 comps='all leader'
220                         ;;
221                         --host|-H)
222                                 comps=$(compgen -A hostname)
223                         ;;
224                         --property|-p)
225                                 comps=''
226                         ;;
227                 esac
228                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
229                 return 0
230         fi
231
232
233         if [[ "$cur" = -* ]]; then
234                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
235                 return 0
236         fi
237
238         local -A VERBS=(
239                 [SESSIONS]='session-status show-session activate lock-session unlock-session terminate-session kill-session'
240                 [USERS]='user-status show-user enable-linger disable-linger terminate-user kill-user'
241                 [SEATS]='seat-status show-seat terminate-seat'
242                 [STANDALONE]='list-sessions list-users list-seats flush-devices'
243                 [ATTACH]='attach'
244         )
245
246         for ((i=0; $i <= $COMP_CWORD; i++)); do
247                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
248                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
249                         verb=${COMP_WORDS[i]}
250                         break
251                 fi
252         done
253
254         if   [[ -z $verb ]]; then
255                 comps="${VERBS[*]}"
256
257         elif __contains_word "$verb" ${VERBS[SESSIONS]}; then
258                 comps=$( __get_all_sessions )
259
260         elif __contains_word "$verb" ${VERBS[USERS]}; then
261                 comps=$( __get_all_users )
262
263         elif __contains_word "$verb" ${VERBS[SEATS]}; then
264                 comps=$( __get_all_seats )
265
266         elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
267                 comps=''
268
269         elif __contains_word "$verb" ${VERBS[ATTACH]}; then
270                 if [[ $prev = $verb ]]; then
271                         comps=$( __get_all_seats )
272                 else
273                         comps=$(compgen -A file -- "$cur" )
274                         compopt -o filenames
275                 fi
276         fi
277
278         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
279         return 0
280 }
281 complete -F _loginctl loginctl
282
283 __journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
284                   ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} COREDUMP_EXE
285                   _{P,U,G}ID _COMM _EXE _CMDLINE
286                   _AUDIT_{SESSION,LOGINUID}
287                   _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
288                   _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
289                   _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
290                   _KERNEL_{DEVICE,SUBSYSTEM}
291                   _UDEV_{SYSNAME,DEVNODE,DEVLINK}
292                   __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
293
294 _journalctl() {
295         local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
296         local -A OPTS=(
297                 [STANDALONE]='-a --all -b --this-boot --disk-usage -f --follow --header
298                               -h --help -l --local --new-id128 -m --merge --no-pager
299                               --no-tail -q --quiet --setup-keys --this-boot --verify
300                               --version --list-catalog --update-catalog'
301                        [ARG]='-D --directory -F --field -o --output -u --unit'
302                 [ARGUNKNOWN]='-c --cursor --interval -n --lines -p --priority --since --until
303                               --verify-key'
304         )
305
306         if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then
307                 case $prev in
308                         --directory|-D)
309                                 comps=$(compgen -d -- "$cur")
310                                 compopt -o filenames
311                         ;;
312                         --output|-o)
313                                 comps='short short-monotonic verbose export json cat'
314                         ;;
315                         --field|-F)
316                                 comps=${__journal_fields[*]}
317                         ;;
318                         --unit|-u)
319                                 comps=$(journalctl -F '_SYSTEMD_UNIT')
320                         ;;
321                         *)
322                                 return 0
323                         ;;
324                 esac
325                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
326                 return 0
327         fi
328
329         if [[ $cur = -* ]]; then
330                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
331                 return 0
332         elif [[ $cur = *=* ]]; then
333                 mapfile -t field_vals < <(journalctl -F "${prev%=}" 2>/dev/null)
334                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
335         elif [[ $prev = '=' ]]; then
336                 mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
337                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") )
338         else
339                 compopt -o nospace
340                 COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
341         fi
342 }
343 complete -F _journalctl journalctl
344
345 _coredumpctl() {
346         local i verb comps
347         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
348         local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field'
349
350         local -A VERBS=(
351             [LIST]='list'
352             [DUMP]='dump gdb'
353         )
354
355         if __contains_word "$prev" '--output -o'; then
356                 comps=$( compgen -A file -- "$cur" )
357                 compopt -o filenames
358         elif __contains_word "$prev" '--FIELD -F'; then
359                 comps=$( compgen -W '${__journal_fields[*]}' -- "$cur" )
360         elif [[ $cur = -* ]]; then
361                 comps=${OPTS}
362         elif __contains_word "$prev" ${VERBS[*]} &&
363            ! __contains_word ${COMP_WORDS[COMP_CWORD-2]} '--output -o -F --field'; then
364                 compopt -o nospace
365                 COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
366                return 0
367         elif [[ $cur = *=* ]]; then
368                 mapfile -t field_vals < <(systemd-coredumpctl -F "${prev%=}" 2>/dev/null)
369                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
370                 return 0
371         elif [[ $prev = '=' ]]; then
372                 mapfile -t field_vals < <(systemd-coredumpctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
373                 comps=${field_vals[*]}
374         else
375                 for ((i=0; i <= COMP_CWORD; i++)); do
376                         if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
377                                 verb=${COMP_WORDS[i]}
378                                 break
379                         fi
380                 done
381
382                 if [[ -z $verb ]]; then
383                         comps=${VERBS[*]}
384                 elif __contains_word "$verb" ${VERBS[LIST]} ${VERBS[DUMP]}; then
385                         comps=''
386                 fi
387         fi
388
389         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
390         return 0
391 }
392 complete -F _coredumpctl systemd-coredumpctl
393
394 _timedatectl() {
395         local i verb comps
396         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
397         local OPTS='-h --help --version --adjust-system-clock --no-pager
398                     --no-ask-password -H --host'
399
400         if __contains_word "$prev" $OPTS; then
401                 case $prev in
402                         --host|-H)
403                                 comps=''
404                         ;;
405                 esac
406                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
407                 return 0
408         fi
409
410         if [[ $cur = -* ]]; then
411                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
412                 return 0
413         fi
414
415         local -A VERBS=(
416                   [BOOLEAN]='set-local-rtc set-ntp'
417                [STANDALONE]='status set-time list-timezones'
418                 [TIMEZONES]='set-timezone'
419                      [TIME]='set-time'
420         )
421
422         for ((i=0; i <= COMP_CWORD; i++)); do
423                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
424                         verb=${COMP_WORDS[i]}
425                         break
426                 fi
427         done
428
429         if [[ -z $verb ]]; then
430                 comps=${VERBS[*]}
431         elif __contains_word "$verb" ${VERBS[BOOLEAN]}; then
432                 comps='true false'
433         elif __contains_word "$verb" ${VERBS[TIMEZONES]}; then
434                 comps=$(command timedatectl list-timezones)
435         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[TIME]}; then
436                 comps=''
437         fi
438
439         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
440         return 0
441 }
442 complete -F _timedatectl timedatectl
443
444 _localectl() {
445         local i verb comps
446         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
447         local OPTS='-h --help --version --no-convert --no-pager --no-ask-password
448                     -H --host'
449
450         if __contains_word "$prev" $OPTS; then
451                 case $prev in
452                         --host|-H)
453                                 comps=''
454                         ;;
455                 esac
456                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
457                 return 0
458         fi
459
460         if [[ $cur = -* ]]; then
461                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
462                 return 0
463         fi
464
465         local -A VERBS=(
466                [STANDALONE]='status list-locales list-keymaps'
467                   [LOCALES]='set-locale'
468                   [KEYMAPS]='set-keymap'
469                       [X11]='set-x11-keymap'
470         )
471
472         for ((i=0; i <= COMP_CWORD; i++)); do
473                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
474                         verb=${COMP_WORDS[i]}
475                         break
476                 fi
477         done
478
479         if [[ -z $verb ]]; then
480                 comps=${VERBS[*]}
481         elif __contains_word "$verb" ${VERBS[LOCALES]}; then
482                 comps=$(command localectl list-locales)
483         elif __contains_word "$verb" ${VERBS[KEYMAPS]}; then
484                 comps=$(command localectl list-keymaps)
485         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[X11]}; then
486                 comps=''
487         fi
488
489         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
490         return 0
491 }
492 complete -F _localectl localectl
493
494 _hostnamectl() {
495         local i verb comps
496         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
497         local OPTS='-h --help --version --transient --static --pretty
498                     --no-ask-password -H --host'
499
500         if [[ $cur = -* ]]; then
501                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
502                 return 0
503         fi
504
505         local -A VERBS=(
506                 [STANDALONE]='status'
507                      [ICONS]='set-icon-name'
508                       [NAME]='set-hostname'
509         )
510
511         for ((i=0; i <= COMP_CWORD; i++)); do
512                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
513                         verb=${COMP_WORDS[i]}
514                         break
515                 fi
516         done
517
518         if [[ -z $verb ]]; then
519                 comps=${VERBS[*]}
520         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[ICONS]} ${VERBS[NAME]}; then
521                 comps=''
522         fi
523
524         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
525         return 0
526 }
527 complete -F _hostnamectl hostnamectl
528
529 __get_all_sysdevs() {
530         local -a devs=(/sys/bus/*/devices/*/ /sys/class/*/*/)
531         printf '%s\n' "${devs[@]%/}"
532 }
533
534 _udevadm() {
535         local i verb comps
536         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
537         local OPTS='-h --help --version --debug'
538
539         local -A VERBS=(
540                 [INFO]='info'
541                 [TRIGGER]='trigger'
542                 [SETTLE]='settle'
543                 [CONTROL]='control'
544                 [MONITOR]='monitor'
545                 [HWDB]='hwdb'
546                 [TESTBUILTIN]='test-builtin'
547                 [TEST]='test'
548         )
549
550         for ((i=0; $i <= $COMP_CWORD; i++)); do
551                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
552                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
553                         verb=${COMP_WORDS[i]}
554                         break
555                 fi
556         done
557
558         if [[ -z $verb  && $cur = -* ]]; then
559                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
560                 return 0
561         fi
562
563         if [[ -z $verb ]]; then
564                 comps=${VERBS[*]}
565
566         elif __contains_word "$verb" ${VERBS[INFO]}; then
567                 if [[ $cur = -* ]]; then
568                         comps='--help --query= --path= --name= --root --attribute-walk --export-db --cleanup-db'
569                 else
570                         comps=$( __get_all_sysdevs )
571                 fi
572
573         elif __contains_word "$verb" ${VERBS[TRIGGER]}; then
574                 comps='--help --verbose --dry-run --type= --action= --subsystem-match=
575                        --subsystem-nomatch= --attr-match= --attr-nomatch= --property-match=
576                        --tag-match= --sysname-match= --parent-match='
577
578         elif __contains_word "$verb" ${VERBS[SETTLE]}; then
579                 comps='--help --timeout= --seq-start= --seq-end= --exit-if-exists= --quiet'
580
581         elif __contains_word "$verb" ${VERBS[CONTROL]}; then
582                 comps='--help --exit --log-priority= --stop-exec-queue --start-exec-queue
583                        --reload --property= --children-max= --timeout='
584
585         elif __contains_word "$verb" ${VERBS[MONITOR]}; then
586                 comps='--help --kernel --udev --property --subsystem-match= --tag-match='
587
588         elif __contains_word "$verb" ${VERBS[HWDB]}; then
589                 comps='--help --update --test='
590
591         elif __contains_word "$verb" ${VERBS[TEST]}; then
592                 if [[ $cur = -* ]]; then
593                         comps='--help --action='
594                 else
595                         comps=$( __get_all_sysdevs )
596                 fi
597
598         elif __contains_word "$verb" ${VERBS[TESTBUILTIN]}; then
599                       comps='blkid btrfs firmware hwdb input_id kmod path_id usb_id uaccess'
600         fi
601
602         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
603         return 0
604 }
605 complete -F _udevadm udevadm