From ba5e44e26bb3dbf52b877133c8bf3e12a0b3d245 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 11 Jun 2024 15:19:56 +0900 Subject: shell-completion: update bash-completion for udevadm - Add missing options. - Show device nodes when supported. Closes #33265. --- shell-completion/bash/udevadm | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/shell-completion/bash/udevadm b/shell-completion/bash/udevadm index fbbaed001c..05f921cf49 100644 --- a/shell-completion/bash/udevadm +++ b/shell-completion/bash/udevadm @@ -31,7 +31,7 @@ __get_all_sysdevs() { printf '%s\n' "${devs[@]%/}" } -__get_all_devs() { +__get_all_device_nodes() { local i for i in /dev/* /dev/*/* /dev/*/*/*; do echo $i @@ -43,15 +43,23 @@ __get_all_device_units() { { while read -r a b; do echo "$a"; done; } } +__get_all_devices() { + __get_all_sysdevs + __get_all_device_nodes + __get_all_device_units +} + _udevadm() { local i verb comps builtin local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [COMMON]='-h --help -V --version' [DEBUG]='-d --debug' - [INFO_STANDALONE]='-r --root -a --attribute-walk -x --export -e --export-db -c --cleanup-db - -w --wait-for-initialization --value' - [INFO_ARG]='-q --query -p --path -n --name -P --export-prefix -d --device-id-of-file --property' + [INFO_STANDALONE]='-r --root -a --attribute-walk -t --tree -x --export -e --export-db -c --cleanup-db + -w --wait-for-initialization --value --no-pager --initialized-match --initialized-nomatch' + [INFO_ARG]='-q --query -p --path -n --name -P --export-prefix -d --device-id-of-file --property + --json --subsystem-match --subsystem-nomatch --attr-match --attr-nomatch --property-match + --tag-match --sysname-match --name-match --parent-match' [TRIGGER_STANDALONE]='-v --verbose -n --dry-run -q --quiet -w --settle --wait-daemon --uuid --initialized-match --initialized-nomatch' [TRIGGER_ARG]='-t --type -c --action -s --subsystem-match -S --subsystem-nomatch @@ -59,7 +67,8 @@ _udevadm() { -g --tag-match -y --sysname-match --name-match -b --parent-match --prioritized-subsystem' [SETTLE]='-t --timeout -E --exit-if-exists' - [CONTROL_STANDALONE]='-e --exit -s --stop-exec-queue -S --start-exec-queue -R --reload --ping' + [CONTROL_STANDALONE]='-e --exit -s --stop-exec-queue -S --start-exec-queue -R --reload --ping + --load-credentials' [CONTROL_ARG]='-l --log-priority -p --property -m --children-max -t --timeout' [MONITOR_STANDALONE]='-k --kernel -u --udev -p --property' [MONITOR_ARG]='-s --subsystem-match -t --tag-match' @@ -101,7 +110,17 @@ _udevadm() { local IFS=$'\n' ;; -n|--name) - comps=$( __get_all_devs ) + comps=$( __get_all_device_nodes ) + ;; + --json) + comps=$( udevadm info --json=help ) + ;; + --parent-match) + comps=$( __get_all_sysdevs ) + local IFS=$'\n' + ;; + --name-match) + comps=$( __get_all_device_nodes ) ;; *) comps='' @@ -114,7 +133,7 @@ _udevadm() { if [[ $cur = -* ]]; then comps="${OPTS[COMMON]} ${OPTS[INFO_STANDALONE]} ${OPTS[INFO_ARG]}" else - comps=$( __get_all_sysdevs; __get_all_device_units ) + comps=$( __get_all_devices ) local IFS=$'\n' fi ;; @@ -133,7 +152,7 @@ _udevadm() { local IFS=$'\n' ;; --name-match) - comps=$( __get_all_devs ) + comps=$( __get_all_device_nodes ) ;; *) comps='' @@ -146,7 +165,7 @@ _udevadm() { if [[ $cur = -* ]]; then comps="${OPTS[COMMON]} ${OPTS[TRIGGER_STANDALONE]} ${OPTS[TRIGGER_ARG]}" else - comps=$( __get_all_sysdevs; __get_all_device_units ) + comps=$( __get_all_devices ) local IFS=$'\n' fi ;; @@ -216,7 +235,7 @@ _udevadm() { if [[ $cur = -* ]]; then comps="${OPTS[COMMON]} ${OPTS[TEST]}" else - comps=$( __get_all_sysdevs ) + comps=$( __get_all_devices ) local IFS=$'\n' fi ;; @@ -244,7 +263,7 @@ _udevadm() { elif [[ $cur = -* ]]; then comps="${OPTS[COMMON]} ${OPTS[TEST_BUILTIN]}" else - comps=$( __get_all_sysdevs ) + comps=$( __get_all_devices ) local IFS=$'\n' fi ;; @@ -288,7 +307,7 @@ _udevadm() { if [[ $cur = -* ]]; then comps="${OPTS[COMMON]} ${OPTS[WAIT]}" else - comps=$( __get_all_devs ) + comps=$( __get_all_devices ) local IFS=$'\n' fi ;; -- cgit v1.2.3