udevadm: introduce cat command

This introduces 'udevadm cat' command, that shows udev rules files or
udev.conf, which may be useful for debugging.

Closes #35818.
This commit is contained in:
Yu Watanabe
2025-01-07 16:58:37 +09:00
parent bbe1ba5e87
commit 7f2175eabb
8 changed files with 225 additions and 1 deletions

View File

@@ -103,11 +103,13 @@ _udevadm() {
[TEST_BUILTIN]='-a --action'
[VERIFY_STANDALONE]='--no-summary --no-style'
[VERIFY_ARG]='-N --resolve-names --root'
[CAT_STANDALONE]='--tldr --config'
[CAT_ARG]='--root'
[WAIT]='-t --timeout --initialized=no --removed --settle'
[LOCK]='-t --timeout -d --device -b --backing -p --print'
)
local verbs=(info trigger settle control monitor test-builtin test verify wait lock)
local verbs=(info trigger settle control monitor test-builtin test verify cat wait lock)
local builtins=(blkid btrfs hwdb input_id keyboard kmod net_driver net_id net_setup_link path_id uaccess usb_id)
for ((i=0; i < COMP_CWORD; i++)); do
@@ -323,6 +325,30 @@ _udevadm() {
fi
;;
'cat')
if __contains_word "$prev" ${OPTS[CAT_ARG]}; then
case $prev in
--root)
comps=''
compopt -o dirnames
;;
*)
comps=''
;;
esac
elif [[ $cur = -* ]]; then
comps="${OPTS[COMMON]} ${OPTS[CAT_ARG]} ${OPTS[CAT_STANDALONE]}"
elif __contains_word "--config" ${COMP_WORDS[*]}; then
comps="${OPTS[COMMON]} ${OPTS[CAT_ARG]} ${OPTS[CAT_STANDALONE]}"
elif [[ $cur = */* ]]; then
comps=$( __get_udev_rules_files )
compopt -o dirnames
else
comps=$( __get_udev_rules_names )
compopt -o default
fi
;;
'wait')
if __contains_word "$prev" ${OPTS[WAIT]}; then
case $prev in