From 840b2c0e77911bef3056f358b8d16a3253e4ab70 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 28 Sep 2015 14:43:26 -0400 Subject: shell-completion: use systemctl --state=help This way completion lists should stay up to date. Also use systemctl -t help to list types in zsh, as was already done in bash. --- shell-completion/bash/systemctl.in | 4 +--- shell-completion/zsh/_systemctl.in | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'shell-completion') diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index 4d63e2870f..c8e17de7bc 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -119,9 +119,7 @@ _systemctl () { comps=$(__systemctl $mode -t help) ;; --state) - comps='loaded not-found stub - active inactive failed - dead elapsed exited listening mounted plugged running waiting' + comps=$(__systemctl $mode --state=help) ;; --job-mode) comps='fail replace replace-irreversibly isolate diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in index 4bf306aacb..96f51a0ee0 100644 --- a/shell-completion/zsh/_systemctl.in +++ b/shell-completion/zsh/_systemctl.in @@ -334,13 +334,13 @@ _systemctl_caching_policy() _unit_states() { local -a _states - _states=(loaded failed active inactive not-found listening running waiting plugged mounted exited dead masked) + _states=("${(fo)$(__systemctl --state=help)}") _values -s , "${_states[@]}" } _unit_types() { local -a _types - _types=(automount busname device mount path service snapshot socket swap target timer) + _types=("${(fo)$(__systemctl -t help)}") _values -s , "${_types[@]}" } -- cgit v1.2.3-54-g00ecf From b00c1cf9d61ccd9b0f7bc131f01d80bb5736af0d Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 28 Sep 2015 15:23:04 -0400 Subject: bash-completion: use builtins when generating list awk is an external program, and it is better to stick to shell built-ins. Also, even with external awk, sort -u is redundant, because the shell does this on its own. --- shell-completion/bash/networkctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shell-completion') diff --git a/shell-completion/bash/networkctl b/shell-completion/bash/networkctl index 7ca2aa5a81..942c7e1c00 100644 --- a/shell-completion/bash/networkctl +++ b/shell-completion/bash/networkctl @@ -24,7 +24,7 @@ __contains_word () { } __get_links() { - networkctl list --no-legend --no-pager --all | awk '{ print $2 }' | sort -u + networkctl list --no-legend --no-pager --all | { while read -r a b c; do echo " $b"; done; }; } _networkctl() { -- cgit v1.2.3-54-g00ecf From db79008804f7bd0e5ef48c454ed6aa58a3dfa268 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 28 Sep 2015 15:42:27 -0400 Subject: bash-completion: use builtins when generating list --- shell-completion/bash/systemd-path | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shell-completion') diff --git a/shell-completion/bash/systemd-path b/shell-completion/bash/systemd-path index cdaf29794e..2f0c5f5bd7 100644 --- a/shell-completion/bash/systemd-path +++ b/shell-completion/bash/systemd-path @@ -24,7 +24,7 @@ __contains_word () { } __get_names() { - systemd-path | cut -d: -f1 | sort -u + systemd-path | { while IFS=: read -r a b; do echo " $a"; done; } } _systemd_path() { -- cgit v1.2.3-54-g00ecf From 4ed2f1b1f106b84276eaf8cc4d27cca54653845e Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 28 Sep 2015 17:23:53 -0400 Subject: bash-completion: remove one more sort and sub-shell {} is preferred to (), because the first is just grouping, while the second invokes a separate shell. --- shell-completion/bash/systemctl.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'shell-completion') diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index c8e17de7bc..29bb41c436 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -87,8 +87,8 @@ __get_all_unit_files () { { __systemctl $1 list-unit-files; } | { while read -r __get_machines() { local a b - (machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager) | \ - { while read a b; do echo " $a"; done; } | sort -u; + { machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager; } | \ + { while read a b; do echo " $a"; done; } } _systemctl () { -- cgit v1.2.3-54-g00ecf