diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-03-26 05:01:40 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-04-01 15:13:18 +0900 |
commit | aa2b0d8d291a1f1dc2b50016c076ff8196989f84 (patch) | |
tree | d3e690218cc7fd5baefae764a079c4eefb15451c /shell-completion | |
parent | 209294ad24ef25beaae630a281d92960b6d0e28c (diff) | |
download | systemd-aa2b0d8d291a1f1dc2b50016c076ff8196989f84.tar.gz |
udevadm: introduce new 'wait' command
Prompted by https://github.com/systemd/systemd/pull/22717#issuecomment-1067348496.
The new command 'udevadm wait' waits for device or device symlink being
created. This may be useful to wait for a device is processed by udevd
after e.g. formatting or partitioning the device.
Diffstat (limited to 'shell-completion')
-rw-r--r-- | shell-completion/bash/udevadm | 24 | ||||
-rw-r--r-- | shell-completion/zsh/_udevadm | 11 |
2 files changed, 33 insertions, 2 deletions
diff --git a/shell-completion/bash/udevadm b/shell-completion/bash/udevadm index 23ce02365c..08446b2d5d 100644 --- a/shell-completion/bash/udevadm +++ b/shell-completion/bash/udevadm @@ -32,7 +32,7 @@ __get_all_sysdevs() { __get_all_devs() { local i - for i in /dev/* /dev/*/*; do + for i in /dev/* /dev/*/* /dev/*/*/*; do echo $i done } @@ -64,9 +64,10 @@ _udevadm() { [MONITOR_ARG]='-s --subsystem-match -t --tag-match' [TEST]='-a --action -N --resolve-names' [TEST_BUILTIN]='-a --action' + [WAIT]='-t --timeout --initialized=no --removed --settle' ) - local verbs=(info trigger settle control monitor test-builtin test) + local verbs=(info trigger settle control monitor test-builtin test wait) local builtins=(blkid btrfs hwdb input_id keyboard kmod net_id net_setup_link path_id usb_id uaccess) for ((i=0; i < COMP_CWORD; i++)); do @@ -245,6 +246,25 @@ _udevadm() { fi ;; + 'wait') + if __contains_word "$prev" ${OPTS[WAIT]}; then + case $prev in + *) + comps='' + ;; + esac + COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) + return 0 + fi + + if [[ $cur = -* ]]; then + comps="${OPTS[COMMON]} ${OPTS[WAIT]}" + else + comps=$( __get_all_devs ) + local IFS=$'\n' + fi + ;; + *) comps=${VERBS[*]} ;; diff --git a/shell-completion/zsh/_udevadm b/shell-completion/zsh/_udevadm index 63df8b7c9e..a277ad7929 100644 --- a/shell-completion/zsh/_udevadm +++ b/shell-completion/zsh/_udevadm @@ -104,6 +104,17 @@ _udevadm_test-builtin(){ fi } +(( $+functions[_udevadm_wait] )) || +_udevadm_wait(){ + _arguments \ + '--timeout=[Maximum number of seconds to wait for the devices being created.]' \ + '--initialized=[Wait for devices being initialized by systemd-udevd.]:boolean:(yes no)' \ + '--removed[Wait for devices being removed.]' \ + '--settle[Also wait for udev queue being empty.]' \ + '--help[Print help text.]' \ + '*::devpath:_files -P /dev/ -W /dev' +} + (( $+functions[_udevadm_mounts] )) || _udevadm_mounts(){ local dev_tmp dpath_tmp mp_tmp mline |