diff options
author | dana <dana@dana.is> | 2018-12-24 05:15:38 -0600 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-01-08 15:23:37 +0100 |
commit | c501ecd70c61f5569bb775be62612521aa53f878 (patch) | |
tree | d8b7bbe730451f3a0cc2473e56f80b4914957e0a /shell-completion | |
parent | f04746604140b5a3bee257b4824df9a035142de6 (diff) | |
download | systemd-c501ecd70c61f5569bb775be62612521aa53f878.tar.gz systemd-c501ecd70c61f5569bb775be62612521aa53f878.tar.bz2 systemd-c501ecd70c61f5569bb775be62612521aa53f878.zip |
zsh completion: Prevent functions from clobbering each other, &c.
- Don't redefine helpers on every call
- Prefix helper names with main function name
- Adjust some helper names for consistency and convention adherance
Diffstat (limited to 'shell-completion')
-rw-r--r-- | shell-completion/zsh/_bootctl | 4 | ||||
-rw-r--r-- | shell-completion/zsh/_busctl | 4 | ||||
-rw-r--r-- | shell-completion/zsh/_coredumpctl | 5 | ||||
-rw-r--r-- | shell-completion/zsh/_hostnamectl | 10 | ||||
-rw-r--r-- | shell-completion/zsh/_journalctl | 34 | ||||
-rw-r--r-- | shell-completion/zsh/_kernel-install | 10 | ||||
-rw-r--r-- | shell-completion/zsh/_localectl | 8 | ||||
-rw-r--r-- | shell-completion/zsh/_loginctl | 7 | ||||
-rw-r--r-- | shell-completion/zsh/_machinectl | 16 | ||||
-rw-r--r-- | shell-completion/zsh/_networkctl | 5 | ||||
-rw-r--r-- | shell-completion/zsh/_sd_machines | 6 | ||||
-rw-r--r-- | shell-completion/zsh/_systemctl.in | 38 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd-analyze | 21 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd-delta | 5 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd-inhibit | 8 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd-nspawn | 7 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd-resolve | 16 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd-run | 11 | ||||
-rw-r--r-- | shell-completion/zsh/_udevadm | 14 |
19 files changed, 147 insertions, 82 deletions
diff --git a/shell-completion/zsh/_bootctl b/shell-completion/zsh/_bootctl index f107005814..0ffef94e4a 100644 --- a/shell-completion/zsh/_bootctl +++ b/shell-completion/zsh/_bootctl @@ -1,7 +1,7 @@ #compdef bootctl # SPDX-License-Identifier: LGPL-2.1+ -(( $+functions[_bootctl_command] )) || _bootctl_command() +(( $+functions[_bootctl_commands] )) || _bootctl_commands() { local -a _bootctl_cmds _bootctl_cmds=( @@ -28,4 +28,4 @@ _arguments \ '--version[Prints a short version string and exits.]' \ '--path=[Path to the EFI System Partition (ESP)]:path:_directories' \ '--no-variables[Do not touch EFI variables]' \ - '*::bootctl command:_bootctl_command' + '*::bootctl command:_bootctl_commands' diff --git a/shell-completion/zsh/_busctl b/shell-completion/zsh/_busctl index 801ed48010..d66ff3e0ce 100644 --- a/shell-completion/zsh/_busctl +++ b/shell-completion/zsh/_busctl @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. -(( $+functions[_busctl_command] )) || _busctl_command() +(( $+functions[_busctl_commands] )) || _busctl_commands() { local -a _busctl_cmds _busctl_cmds=( @@ -68,4 +68,4 @@ _arguments \ '--allow-interactive-authorization=[Allow interactive authorization for operation]:boolean:(1 0)' \ '--timeout=[Maximum time to wait for method call completion]:timeout (seconds)' \ '--augment-creds=[Extend credential data with data read from /proc/$PID]:boolean:(1 0)' \ - '*::busctl command:_busctl_command' + '*::busctl command:_busctl_commands' diff --git a/shell-completion/zsh/_coredumpctl b/shell-completion/zsh/_coredumpctl index 720d02a3ef..e446ad349c 100644 --- a/shell-completion/zsh/_coredumpctl +++ b/shell-completion/zsh/_coredumpctl @@ -1,7 +1,8 @@ #compdef coredumpctl # SPDX-License-Identifier: LGPL-2.1+ -_coredumpctl_command(){ +(( $+functions[_coredumpctl_commands] )) || +_coredumpctl_commands(){ local -a _coredumpctl_cmds _coredumpctl_cmds=( 'list:List available coredumps' @@ -42,4 +43,4 @@ _arguments \ '--debugger=[Use the given debugger]:debugger: _command_names -e' \ {-D,--directory=}'[Use the journal files in the specified dir]:directory: _directories' \ {-q,--quiet}'[Do not show info messages and privilege warning]' \ - '*::coredumpctl commands:_coredumpctl_command' + '*::coredumpctl commands:_coredumpctl_commands' diff --git a/shell-completion/zsh/_hostnamectl b/shell-completion/zsh/_hostnamectl index ea86863e5a..a5c89306d1 100644 --- a/shell-completion/zsh/_hostnamectl +++ b/shell-completion/zsh/_hostnamectl @@ -1,6 +1,7 @@ #compdef hostnamectl # SPDX-License-Identifier: LGPL-2.1+ +(( $+functions[_hostnamectl_set-hostname] )) || _hostnamectl_set-hostname() { if (( CURRENT <= 3 )); then _message "new hostname" @@ -9,6 +10,7 @@ _hostnamectl_set-hostname() { fi } +(( $+functions[_hostnamectl_set-icon-name] )) || _hostnamectl_set-icon-name() { if (( CURRENT <= 3 )); then _message "new icon name" @@ -17,6 +19,7 @@ _hostnamectl_set-icon-name() { fi } +(( $+functions[_hostnamectl_set-chassis] )) || _hostnamectl_set-chassis() { if (( CURRENT <= 3 )); then _chassis=( desktop laptop convertible server tablet handset watch embedded vm container ) @@ -26,6 +29,7 @@ _hostnamectl_set-chassis() { fi } +(( $+functions[_hostnamectl_set-deployment] )) || _hostnamectl_set-deployment() { if (( CURRENT <= 3 )); then _message "new environment" @@ -34,6 +38,7 @@ _hostnamectl_set-deployment() { fi } +(( $+functions[_hostnamectl_set-location] )) || _hostnamectl_set-location() { if (( CURRENT <= 3 )); then _message "new location" @@ -42,7 +47,8 @@ _hostnamectl_set-location() { fi } -_hostnamectl_command() { +(( $+functions[_hostnamectl_commands] )) || +_hostnamectl_commands() { local -a _hostnamectl_cmds _hostnamectl_cmds=( "status:Show current hostname settings" @@ -78,4 +84,4 @@ _arguments -s \ '--no-ask-password[Do not prompt for password]' \ {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ - '*::hostnamectl commands:_hostnamectl_command' + '*::hostnamectl commands:_hostnamectl_commands' diff --git a/shell-completion/zsh/_journalctl b/shell-completion/zsh/_journalctl index 4bffabba96..aa6ace0485 100644 --- a/shell-completion/zsh/_journalctl +++ b/shell-completion/zsh/_journalctl @@ -1,7 +1,8 @@ #compdef journalctl # SPDX-License-Identifier: LGPL-2.1+ -_list_fields() { +(( $+functions[_journalctl_fields] )) || +_journalctl_fields() { local -a journal_fields journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC} ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} @@ -16,12 +17,13 @@ _list_fields() { __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP) case $_jrnl_none in yes) _values -s '=' 'possible fields' \ - "${journal_fields[@]}:value:_journal_fields ${words[CURRENT]%%=*}" ;; + "${journal_fields[@]}:value:_journalctl_field_values ${words[CURRENT]%%=*}" ;; *) _describe 'possible fields' journal_fields ;; esac } -_journal_none() { +(( $+functions[_journalctl_none] )) || +_journalctl_none() { local -a _commands _files _jrnl_none # Setting use-cache will slow this down considerably _commands=( ${"$(_call_program commands "$service $_sys_service_mgr -F _EXE" 2>/dev/null)"} ) @@ -29,10 +31,11 @@ _journal_none() { _alternative : \ 'files:/dev files:_files -W /dev -P /dev/' \ "commands:commands:($_commands[@])" \ - 'fields:fields:_list_fields' + 'fields:fields:_journalctl_fields' } -_journal_fields() { +(( $+functions[_journalctl_field_values] )) || +_journalctl_field_values() { local -a _fields cmd cmd=("journalctl $_sys_service_mgr" "-F ${@[-1]}" "2>/dev/null" ) _fields=$(_call_program fields $cmd[@]) @@ -43,7 +46,8 @@ _journal_fields() { _describe 'possible values' _fields } -_journal_boots() { +(( $+functions[_journalctl_boots] )) || +_journalctl_boots() { local -a _bootid _previousboots _bootid=( ${(f)"$(_call_program bootid "$service -F _BOOT_ID")"} ) _previousboots=( -{1..${#_bootid}} ) @@ -92,18 +96,18 @@ _arguments -s \ {-x,--catalog}'[Show explanatory texts with each log line]' \ {-q,--quiet}"[Don't show privilege warning]" \ {-m,--merge}'[Show entries from all available journals]' \ - {-b+,--boot=}'[Show data only from the specified boot or offset]::boot id or offset:_journal_boots' \ + {-b+,--boot=}'[Show data only from the specified boot or offset]::boot id or offset:_journalctl_boots' \ '--list-boots[List boots ordered by time]' \ {-k,--dmesg}'[Show only kernel messages from the current boot]' \ - {-u+,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \ - '--user-unit=[Show data only from the specified user session unit]:units:_journal_fields USER_UNIT' \ - {-p+,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \ - {-t+,--identifier=}'[Show only messages with the specified syslog identifier]:identifier:_journal_fields SYSLOG_IDENTIFIER' \ - {-c+,--cursor=}'[Start showing entries from the specified cursor]:cursors:_journal_fields __CURSORS' \ - '--after-cursor=[Start showing entries from after the specified cursor]:cursors:_journal_fields __CURSORS' \ + {-u+,--unit=}'[Show data only from the specified unit]:units:_journalctl_field_values _SYSTEMD_UNIT' \ + '--user-unit=[Show data only from the specified user session unit]:units:_journalctl_field_values USER_UNIT' \ + {-p+,--priority=}'[Show only messages within the specified priority range]:priority:_journalctl_field_values PRIORITY' \ + {-t+,--identifier=}'[Show only messages with the specified syslog identifier]:identifier:_journalctl_field_values SYSLOG_IDENTIFIER' \ + {-c+,--cursor=}'[Start showing entries from the specified cursor]:cursors:_journalctl_field_values __CURSORS' \ + '--after-cursor=[Start showing entries from after the specified cursor]:cursors:_journalctl_field_values __CURSORS' \ '--since=[Start showing entries on or newer than the specified date]:YYYY-MM-DD HH\:MM\:SS' \ '--until=[Stop showing entries on or older than the specified date]:YYYY-MM-DD HH\:MM\:SS' \ - {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \ + {-F,--field=}'[List all values a certain field takes]:Fields:_journalctl_fields' \ '--system[Show system and kernel messages]' \ '--user[Show messages from user services]' \ '(--directory -D -M --machine --root --file)'{-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ @@ -121,4 +125,4 @@ _arguments -s \ '--interval=[Time interval for changing the FSS sealing key]:time interval' \ '--verify[Verify journal file consistency]' \ '--verify-key=[Specify FSS verification key]:FSS key' \ - '*::default: _journal_none' + '*::default: _journalctl_none' diff --git a/shell-completion/zsh/_kernel-install b/shell-completion/zsh/_kernel-install index 6358a64589..14793c2f3f 100644 --- a/shell-completion/zsh/_kernel-install +++ b/shell-completion/zsh/_kernel-install @@ -1,7 +1,8 @@ #compdef kernel-install # SPDX-License-Identifier: LGPL-2.1+ -_images(){ +(( $+functions[_kernel-install_images] )) || +_kernel-install_images(){ if [[ "$words[2]" == "remove" ]]; then _message 'No more options' else @@ -9,7 +10,8 @@ _images(){ fi } -_kernels(){ +(( $+functions[_kernel-install_kernels] )) || +_kernel-install_kernels(){ read _MACHINE_ID < /etc/machine-id _kernel=( /lib/modules/[0-9]* ) if [[ "$cmd" == "remove" && -n "$_MACHINE_ID" ]]; then @@ -21,7 +23,7 @@ _kernels(){ _arguments \ '1::add or remove:(add remove)' \ - '2::kernel versions:_kernels' \ - '3::kernel images:_images' + '2::kernel versions:_kernel-install_kernels' \ + '3::kernel images:_kernel-install_images' #vim: set ft=zsh sw=4 ts=4 et diff --git a/shell-completion/zsh/_localectl b/shell-completion/zsh/_localectl index e5ec65b53b..569f4f294c 100644 --- a/shell-completion/zsh/_localectl +++ b/shell-completion/zsh/_localectl @@ -1,6 +1,7 @@ #compdef localectl # SPDX-License-Identifier: LGPL-2.1+ +(( $+functions[_localectl_set-locale] )) || _localectl_set-locale() { local -a _locales locale_fields locale_fields=(LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME \ @@ -21,6 +22,7 @@ _localectl_set-locale() { fi } +(( $+functions[_localectl_set-keymap] )) || _localectl_set-keymap() { local -a _keymaps if (( CURRENT <= 3 )); then @@ -31,6 +33,7 @@ _localectl_set-keymap() { fi } +(( $+functions[_localectl_set-x11-keymap] )) || _localectl_set-x11-keymap() { if (( $+commands[pkg-config] )); then local -a _file _layout _model _variant _options @@ -56,7 +59,8 @@ _localectl_set-x11-keymap() { fi } -_localectl_command() { +(( $+functions[_localectl_commands] )) || +_localectl_commands() { local -a _localectl_cmds _localectl_cmds=( 'status:Show current locale settings' @@ -91,4 +95,4 @@ _arguments \ '--no-ask-password[Do not prompt for password]' \ {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ {-M+,--machine=}'[Operate on local container]:machine' \ - '*::localectl commands:_localectl_command' + '*::localectl commands:_localectl_commands' diff --git a/shell-completion/zsh/_loginctl b/shell-completion/zsh/_loginctl index 03dde9a891..44d6d08c98 100644 --- a/shell-completion/zsh/_loginctl +++ b/shell-completion/zsh/_loginctl @@ -1,6 +1,7 @@ #compdef loginctl # SPDX-License-Identifier: LGPL-2.1+ +(( $+functions[_loginctl_all_sessions] )) || _loginctl_all_sessions() { local session description loginctl --no-legend list-sessions | while read -r session description; do @@ -9,6 +10,7 @@ _loginctl_all_sessions() { done } +(( $+functions[_loginctl_all_users] )) || _loginctl_all_users() { local uid description loginctl --no-legend list-users | while read -r uid description; do @@ -17,6 +19,7 @@ _loginctl_all_users() { done } +(( $+functions[_loginctl_all_seats] )) || _loginctl_all_seats() { local seat description loginctl --no-legend list-seats | while read -r seat description; do @@ -107,7 +110,7 @@ done # no loginctl completion for: # [STANDALONE]='list-sessions list-users list-seats flush-devices' -(( $+functions[_loginctl_command] )) || _loginctl_command() +(( $+functions[_loginctl_commands] )) || _loginctl_commands() { local -a _loginctl_cmds _loginctl_cmds=( @@ -170,4 +173,4 @@ _arguments -s \ '--no-ask-password[Do not ask for system passwords]' \ {-n+,--lines=}'[Number of journal entries to show]' \ {-o+,--output=}'[Change journal output mode]:output modes:_sd_outputmodes' \ - '*::loginctl command:_loginctl_command' + '*::loginctl command:_loginctl_commands' diff --git a/shell-completion/zsh/_machinectl b/shell-completion/zsh/_machinectl index a00fc91021..4561e4db75 100644 --- a/shell-completion/zsh/_machinectl +++ b/shell-completion/zsh/_machinectl @@ -1,13 +1,15 @@ #compdef machinectl # SPDX-License-Identifier: LGPL-2.1+ -__get_available_machines () { +(( $+functions[__machinectl_get_machines] )) || +__machinectl_get_machines () { machinectl --no-legend list-images | {while read -r a b; do echo $a; done;} } -_available_machines() { +(( $+functions[_machinectl_machines] )) || +_machinectl_machines() { local -a _machines - _machines=("${(fo)$(__get_available_machines)}") + _machines=("${(fo)$(__machinectl_get_machines)}") typeset -U _machines if [[ -n "$_machines" ]]; then _describe 'machines' _machines @@ -16,7 +18,7 @@ _available_machines() { fi } -(( $+functions[_machinectl_command] )) || _machinectl_command() +(( $+functions[_machinectl_commands] )) || _machinectl_commands() { local -a _machinectl_cmds _machinectl_cmds=( @@ -61,9 +63,9 @@ _available_machines() { list*|cancel-transfer|pull-tar|pull-raw) msg="no options" ;; clone) - _available_machines ;; + _machinectl_machines ;; start) - _available_machines ;; + _machinectl_machines ;; *) _sd_machines esac @@ -100,4 +102,4 @@ _arguments \ {-o+,--output=}'[Change journal output mode.]:output modes:_sd_outputmodes' \ '--verify=[Verification mode for downloaded images.]:verify:(no checksum signature)' \ '--force[Download image even if already exists.]' \ - '*::machinectl command:_machinectl_command' + '*::machinectl command:_machinectl_commands' diff --git a/shell-completion/zsh/_networkctl b/shell-completion/zsh/_networkctl index ea485d653c..ab62a6d9bf 100644 --- a/shell-completion/zsh/_networkctl +++ b/shell-completion/zsh/_networkctl @@ -1,7 +1,8 @@ #compdef networkctl # SPDX-License-Identifier: LGPL-2.1+ -_networkctl_command(){ +(( $+functions[_networkctl_commands] )) || +_networkctl_commands(){ local -a _networkctl_cmds _networkctl_cmds=( 'list:List existing links' @@ -34,4 +35,4 @@ _arguments \ '--no-legend[Do not print the column headers]' \ {-h,--help}'[Show this help]' \ '--version[Show package version]' \ - '*::networkctl commands:_networkctl_command' + '*::networkctl commands:_networkctl_commands' diff --git a/shell-completion/zsh/_sd_machines b/shell-completion/zsh/_sd_machines index ab35cf84b3..e783620b97 100644 --- a/shell-completion/zsh/_sd_machines +++ b/shell-completion/zsh/_sd_machines @@ -1,11 +1,13 @@ #autoload # SPDX-License-Identifier: LGPL-2.1+ -__get_machines () { + +(( $+functions[__sd_machines_get_machines] )) || +__sd_machines_get_machines () { machinectl --full --no-legend --no-pager list | {while read -r a b; do echo $a; done;}; } local -a _machines -_machines=("${(fo)$(__get_machines)}") +_machines=("${(fo)$(__sd_machines_get_machines)}") typeset -U _machines if [[ -n "$_machines" ]]; then _describe 'machines' _machines diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in index 782d243131..590fc49604 100644 --- a/shell-completion/zsh/_systemctl.in +++ b/shell-completion/zsh/_systemctl.in @@ -1,7 +1,7 @@ #compdef systemctl # SPDX-License-Identifier: LGPL-2.1+ -(( $+functions[_systemctl_command] )) || _systemctl_command() +(( $+functions[_systemctl_commands] )) || _systemctl_commands() { local -a _systemctl_cmds _systemctl_cmds=( @@ -95,6 +95,7 @@ fi } +# @todo _systemd-run has a helper with the same name, so we must redefine __systemctl() { systemctl $_sys_service_mgr --full --no-legend --no-pager "$@" 2>/dev/null @@ -102,6 +103,7 @@ __systemctl() # Fills the unit list +(( $+functions[_systemctl_all_units] )) || _systemctl_all_units() { if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS$_sys_service_mgr ) || @@ -113,6 +115,7 @@ _systemctl_all_units() } # Fills the unit list including all file units +(( $+functions[_systemctl_really_all_units] )) || _systemctl_really_all_units() { local -a all_unit_files; @@ -128,6 +131,7 @@ _systemctl_really_all_units() fi } +(( $+functions[_filter_units_by_property] )) || _filter_units_by_property() { local property=$1 value=$2; shift 2 local -a units; units=("${(q-)@}") @@ -136,16 +140,19 @@ _filter_units_by_property() { echo -E - "${(@g:o:)${(k@)props[(Re)$property=$value]}#Id=}" } +(( $+functions[_systemctl_get_non_template_names] )) || _systemctl_get_non_template_names() { echo -E - ${^${(R)${(f)"$( __systemctl $mode list-unit-files "$PREFIX*" __systemctl $mode list-units --all "$PREFIX*" )"}:#*@.*}%%[[:space:]]*} } +(( $+functions[_systemctl_get_template_names] )) || _systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files "$PREFIX*" )"}##*@.[^[:space:]]##}%%@.*}\@ } - +(( $+functions[_systemctl_active_units] )) || _systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units "$PREFIX*" )"}%% *} )} +(( $+functions[_systemctl_startable_units] )) || _systemctl_startable_units(){ _sys_startable_units=( $( _filter_units_by_property ActiveState inactive $( _filter_units_by_property CanStart yes ${${${(f)"$( @@ -155,6 +162,7 @@ _systemctl_startable_units(){ )) ) } +(( $+functions[_systemctl_restartable_units] )) || _systemctl_restartable_units(){ _sys_restartable_units=( $( _filter_units_by_property CanStart yes ${${${(f)"$( __systemctl $mode list-unit-files --state enabled,disabled,static "$PREFIX*" @@ -162,7 +170,10 @@ _systemctl_restartable_units(){ )"}:#*@.*}%%[[:space:]]*} ) ) } +(( $+functions[_systemctl_failed_units] )) || _systemctl_failed_units() {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed "$PREFIX*" )"}%% *} ) } + +(( $+functions[_systemctl_unit_state] )) || _systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files "$PREFIX*" ) ) } local fun @@ -316,6 +327,7 @@ done # emergency exit halt kexec list-jobs list-units # list-unit-files poweroff reboot rescue show-environment' +(( $+functions[_systemctl_caching_policy] )) || _systemctl_caching_policy() { local _sysunits @@ -336,19 +348,22 @@ _systemctl_caching_policy() return 1 } -_unit_states() { +(( $+functions[_systemctl_unit_states] )) || +_systemctl_unit_states() { local -a _states _states=("${(fo)$(__systemctl --state=help)}") _values -s , "${_states[@]}" } -_unit_types() { +(( $+functions[_systemctl_unit_types] )) || +_systemctl_unit_types() { local -a _types _types=("${(fo)$(__systemctl -t help)}") _values -s , "${_types[@]}" } -_unit_properties() { +(( $+functions[_systemctl_unit_properties] )) || +_systemctl_unit_properties() { if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES$_sys_service_mgr ) || ! _retrieve_cache SYS_ALL_PROPERTIES$_sys_service_mgr; then @@ -358,7 +373,8 @@ _unit_properties() { _values -s , "${_sys_all_properties[@]}" } -_job_modes() { +(( $+functions[_systemctl_job_modes] )) || +_systemctl_job_modes() { local -a _modes _modes=(fail replace replace-irreversibly isolate ignore-dependencies ignore-requirements flush) _values -s , "${_modes[@]}" @@ -371,10 +387,10 @@ local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]} _arguments -s \ {-h,--help}'[Show help]' \ '--version[Show package version]' \ - {-t+,--type=}'[List only units of a particular type]:unit type:_unit_types' \ - '--state=[Display units in the specified state]:unit state:_unit_states' \ - '--job-mode=[Specify how to deal with other jobs]:mode:_job_modes' \ - {-p+,--property=}'[Show only properties by specific name]:unit property:_unit_properties' \ + {-t+,--type=}'[List only units of a particular type]:unit type:_systemctl_unit_types' \ + '--state=[Display units in the specified state]:unit state:_systemctl_unit_states' \ + '--job-mode=[Specify how to deal with other jobs]:mode:_systemctl_job_modes' \ + {-p+,--property=}'[Show only properties by specific name]:unit property:_systemctl_unit_properties' \ {-a,--all}'[Show all units/properties, including dead/empty ones]' \ '--reverse[Show reverse dependencies]' \ '--after[Show units ordered after]' \ @@ -404,4 +420,4 @@ _arguments -s \ '--firmware-setup[Tell the firmware to show the setup menu on next boot]' \ '--plain[When used with list-dependencies, print output as a list]' \ '--failed[Show failed units]' \ - '*::systemctl command:_systemctl_command' + '*::systemctl command:_systemctl_commands' diff --git a/shell-completion/zsh/_systemd-analyze b/shell-completion/zsh/_systemd-analyze index 56982e3d11..64d418e643 100644 --- a/shell-completion/zsh/_systemd-analyze +++ b/shell-completion/zsh/_systemd-analyze @@ -1,29 +1,34 @@ #compdef systemd-analyze # SPDX-License-Identifier: LGPL-2.1+ -_systemd_analyze_log-level() { +(( $+functions[_systemd-analyze_log-level] )) || +_systemd-analyze_log-level() { local -a _levels _levels=(debug info notice warning err crit alert emerg) _describe -t level 'logging level' _levels || compadd "$@" } -_systemd_analyze_log-target() { +(( $+functions[_systemd-analyze_log-target] )) || +_systemd-analyze_log-target() { local -a _targets _targets=(console journal kmsg journal-or-kmsg null) _describe -t target 'logging target' _targets || compadd "$@" } -_systemd_analyze_verify() { +(( $+functions[_systemd-analyze_verify] )) || +_systemd-analyze_verify() { _sd_unit_files } -_systemd_analyze_service-watchdogs() { +(( $+functions[_systemd-analyze_service-watchdogs] )) || +_systemd-analyze_service-watchdogs() { local -a _states _states=(on off) _describe -t state 'state' _states || compadd "$@" } -_systemd_analyze_command(){ +(( $+functions[_systemd-analyze_commands] )) || +_systemd-analyze_commands(){ local -a _systemd_analyze_cmds # Descriptions taken from systemd-analyze --help. _systemd_analyze_cmds=( @@ -48,8 +53,8 @@ _systemd_analyze_command(){ local curcontext="$curcontext" cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}" if (( $#cmd )); then - if (( $+functions[_systemd_analyze_$cmd] )) && (( CURRENT == 2 )); then - _systemd_analyze_$cmd + if (( $+functions[_systemd-analyze_$cmd] )) && (( CURRENT == 2 )); then + _systemd-analyze_$cmd else _message "no more options" fi @@ -74,4 +79,4 @@ _arguments \ '--to-pattern=[When generating a dependency graph, filter only destinations]:GLOB' \ {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ {-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \ - '*::systemd-analyze commands:_systemd_analyze_command' + '*::systemd-analyze commands:_systemd-analyze_commands' diff --git a/shell-completion/zsh/_systemd-delta b/shell-completion/zsh/_systemd-delta index 44e4cb3791..e07bbc8b2b 100644 --- a/shell-completion/zsh/_systemd-delta +++ b/shell-completion/zsh/_systemd-delta @@ -1,7 +1,8 @@ #compdef systemd-delta # SPDX-License-Identifier: LGPL-2.1+ -_delta_type() { +(( $+functions[_systemd-delta_types] )) || +_systemd-delta_types() { local -a _delta_types _delta_types=(masked equivalent redirected overridden unchanged) _values -s , "${_delta_types[@]}" @@ -12,5 +13,5 @@ _arguments \ '--version[Show package version]' \ '--no-pager[Do not pipe output into a pager]' \ '--diff=[Show a diff when overridden files differ]:boolean:(1 0)' \ - {-t+,--type=}'[Only display a selected set of override types]:types:_delta_type' \ + {-t+,--type=}'[Only display a selected set of override types]:types:_systemd-delta_types' \ ':SUFFIX:(tmpfiles.d sysctl.d systemd/system)' diff --git a/shell-completion/zsh/_systemd-inhibit b/shell-completion/zsh/_systemd-inhibit index 764713e28a..7c40e49ae4 100644 --- a/shell-completion/zsh/_systemd-inhibit +++ b/shell-completion/zsh/_systemd-inhibit @@ -1,7 +1,8 @@ #compdef systemd-inhibit # SPDX-License-Identifier: LGPL-2.1+ -_systemd_inhibit_command(){ +(( $+functions[_systemd-inhibit_commands] )) || +_systemd-inhibit_commands(){ if (( CURRENT == 1 )); then compset -q _normal @@ -17,7 +18,8 @@ _systemd_inhibit_command(){ fi } -_inhibit_what() { +(( $+functions[_systemd-inhibit_what] )) || +_systemd-inhibit_what() { local _inhibit _inhibit=(shutdown sleep idle handle-power-key handle-suspend-key handle-hibernate-key handle-lid-switch) _values -s : "${_inhibit[@]}" @@ -31,4 +33,4 @@ _arguments \ '--why=[A descriptive string why is being inhibited]:reason for the lock:' \ '--mode=[One of block or delay]:lock mode:( block delay )' \ '--list[List active inhibitors]' \ - '*:commands:_systemd_inhibit_command' + '*:commands:_systemd-inhibit_commands' diff --git a/shell-completion/zsh/_systemd-nspawn b/shell-completion/zsh/_systemd-nspawn index e0bedee2aa..abaabfc895 100644 --- a/shell-completion/zsh/_systemd-nspawn +++ b/shell-completion/zsh/_systemd-nspawn @@ -1,7 +1,8 @@ #compdef systemd-nspawn # SPDX-License-Identifier: LGPL-2.1+ -_nspawn-caps(){ +(( $+functions[_systemd-nspawn_caps] )) || +_systemd-nspawn_caps(){ local -a _caps _caps=( CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_FSETID CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE @@ -33,8 +34,8 @@ _arguments \ {--port=,-p+}'[Expose a container IP port on the host.]: : _message port' \ {--selinux-context=,-Z+}'[Sets the SELinux security context to be used to label processes in the container.]: : _message "SELinux context"' \ {--selinux-apifs-context=,-L+}'[Sets the SELinux security context to be used to label files in the virtual API file systems in the container.]: : _message "SELinux context"' \ - '--capability=[List one or more additional capabilities to grant the container.]:capabilities:_nspawn-caps' \ - '--drop-capability=[Specify one or more additional capabilities to drop for the containerm]:capabilities:_nspawn-caps' \ + '--capability=[List one or more additional capabilities to grant the container.]:capabilities:_systemd-nspawn_caps' \ + '--drop-capability=[Specify one or more additional capabilities to drop for the containerm]:capabilities:_systemd-nspawn_caps' \ "--link-journal=[Control whether the container's journal shall be made visible to the host system.]:options:(no host guest auto)" \ '-j[Equivalent to --link-journal=guest.]' \ '--read-only[Mount the root file system read only for the container.]' \ diff --git a/shell-completion/zsh/_systemd-resolve b/shell-completion/zsh/_systemd-resolve index b54d22f816..c4664422ec 100644 --- a/shell-completion/zsh/_systemd-resolve +++ b/shell-completion/zsh/_systemd-resolve @@ -17,24 +17,28 @@ # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. -_dns_protocol() { +(( $+functions[_systemd-resolve_protocols] )) || +_systemd-resolve_protocols() { local -a _protocol _protocol=( $(_call_program protocol ${service} --legend=no --protocol help; echo help) ) _values 'protocol' "$_protocol[@]" } -_dns_type() { +(( $+functions[_systemd-resolve_types] )) || +_systemd-resolve_types() { local -a _type _type=( $(_call_program type ${service} --legend=no --type help; echo help) ) _values 'type' "$_type[@]" } -_dns_class() { +(( $+functions[_systemd-resolve_classes] )) || +_systemd-resolve_classes() { local -a _class _class=( $(_call_program class ${service} --legend=no --class help; echo help) ) _values 'class' "$_class[@]" } +(( $+functions[_systemd-resolve_none] )) || _systemd-resolve_none() { _alternative : \ 'domain:DNS address:' \ @@ -48,9 +52,9 @@ _arguments \ '-4[Resolve IPv4 addresses]' \ '-6[Resolve IPv6 addresses]' \ {-i+,--interface=}'[Look on interface]:interface:_net_interfaces' \ - {-p+,--protocol=}'[Look via protocol]:protocol:_dns_protocol' \ - {-t+,--type=}'[Query RR with DNS type]:type:_dns_type' \ - {-c+,--class=}'[Query RR with DNS class]:class:_dns_class' \ + {-p+,--protocol=}'[Look via protocol]:protocol:_systemd-resolve_protocols' \ + {-t+,--type=}'[Query RR with DNS type]:type:_systemd-resolve_types' \ + {-c+,--class=}'[Query RR with DNS class]:class:_systemd-resolve_classes' \ '--service[Resolve services]' \ '--service-address=no[Do not resolve address for services]' \ '--service-txt=no[Do not resolve TXT records for services]' \ diff --git a/shell-completion/zsh/_systemd-run b/shell-completion/zsh/_systemd-run index a8a8e6fe34..81017180a7 100644 --- a/shell-completion/zsh/_systemd-run +++ b/shell-completion/zsh/_systemd-run @@ -1,20 +1,23 @@ #compdef systemd-run # SPDX-License-Identifier: LGPL-2.1+ +# @todo _systemctl has a helper with the same name, so we must redefine __systemctl() { local -a _modes _modes=("--user" "--system") systemctl ${words:*_modes} --full --no-legend --no-pager "$@" 2>/dev/null } -__get_slices () { +(( $+functions[__systemd-run_get_slices] )) || +__systemd-run_get_slices () { __systemctl list-units --all -t slice \ | { while read -r a b; do echo $a; done; }; } -__slices () { +(( $+functions[__systemd-run_slices] )) || +__systemd-run_slices () { local -a _slices - _slices=(${(fo)"$(__get_slices)"}) + _slices=(${(fo)"$(__systemd-run_get_slices)"}) typeset -U _slices _describe 'slices' _slices } @@ -43,7 +46,7 @@ _arguments \ ProtectSystem= ProtectHome= RuntimeDirectory= PassEnvironment= \ ))' \ '--description=[Description for unit]:description' \ - '--slice=[Run in the specified slice]:slices:__slices' \ + '--slice=[Run in the specified slice]:slices:__systemd-run_slices' \ {-r,--remain-after-exit}'[Leave service around until explicitly stopped]' \ '--send-sighup[Send SIGHUP when terminating]' \ '--service-type=[Service type]:type:(simple forking oneshot dbus notify idle)' \ diff --git a/shell-completion/zsh/_udevadm b/shell-completion/zsh/_udevadm index c6bd685aee..020759b006 100644 --- a/shell-completion/zsh/_udevadm +++ b/shell-completion/zsh/_udevadm @@ -1,6 +1,7 @@ #compdef udevadm # SPDX-License-Identifier: LGPL-2.1+ +(( $+functions[_udevadm_info] )) || _udevadm_info(){ _arguments \ '--query=[Query the database for specified type of device data. It needs the --path or --name to identify the specified device.]:type:(name symlink path property all)' \ @@ -15,6 +16,7 @@ _udevadm_info(){ '--cleanup-db[Cleanup the udev database.]' } +(( $+functions[_udevadm_trigger] )) || _udevadm_trigger(){ _arguments \ '--verbose[Print the list of devices which will be triggered.]' \ @@ -31,6 +33,7 @@ _udevadm_trigger(){ '--parent-match=[Trigger events for all children of a given device.]' } +(( $+functions[_udevadm_settle] )) || _udevadm_settle(){ _arguments \ '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \ @@ -41,6 +44,7 @@ _udevadm_settle(){ '--help[Print help text.]' } +(( $+functions[_udevadm_control] )) || _udevadm_control(){ _arguments \ '--exit[Signal and wait for systemd-udevd to exit.]' \ @@ -54,6 +58,7 @@ _udevadm_control(){ '--help[Print help text.]' } +(( $+functions[_udevadm_monitor] )) || _udevadm_monitor(){ _arguments \ '--kernel[Print the kernel uevents.]' \ @@ -64,6 +69,7 @@ _udevadm_monitor(){ '--help[Print help text.]' } +(( $+functions[_udevadm_test] )) || _udevadm_test(){ _arguments \ '--action=[The action string.]:actions:(add change remove)' \ @@ -72,6 +78,7 @@ _udevadm_test(){ '*::devpath:_files -P /sys/ -W /sys' } +(( $+functions[_udevadm_test-builtin] )) || _udevadm_test-builtin(){ if (( CURRENT == 2 )); then _arguments \ @@ -87,6 +94,7 @@ _udevadm_test-builtin(){ fi } +(( $+functions[_udevadm_mounts] )) || _udevadm_mounts(){ local dev_tmp dpath_tmp mp_tmp mline @@ -104,8 +112,8 @@ _udevadm_mounts(){ 'directories:mount point:compadd -a mp_tmp' } - -_udevadm_command(){ +(( $+functions[_udevadm_commands] )) || +_udevadm_commands(){ local -a _udevadm_cmds _udevadm_cmds=( 'info:query sysfs or the udev database' @@ -139,4 +147,4 @@ _arguments \ '--debug[Print debug messages to stderr]' \ '--version[Print version number]' \ '--help[Print help text]' \ - '*::udevadm commands:_udevadm_command' + '*::udevadm commands:_udevadm_commands' |