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-23 22:23:45 +09:00
parent bbe1ba5e87
commit 7f2175eabb
8 changed files with 225 additions and 1 deletions
+27 -1
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
+11
View File
@@ -126,6 +126,17 @@ _udevadm_verify(){
'*::files:_files'
}
(( $+functions[_udevadm_cat] )) ||
_udevadm_cat(){
_arguments \
'(- *)'{-h,--help}'[Show help]' \
'(- *)'{-V,--version}'[Show package version]' \
'--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \
--tldr'[Skip comments and empty lines.]' \
--config'[Show udev.conf.]' \
'*::files:_files'
}
(( $+functions[_udevadm_wait] )) ||
_udevadm_wait(){
_arguments \