shell-completions: code cleanup

This commit is contained in:
Frantisek Sumsal 2023-09-04 10:56:18 +02:00
parent 9dd8858281
commit 05ebcbd5c5

View file

@ -1,4 +1,5 @@
# systemctl(1) completion -*- shell-script -*- # systemctl(1) completion -*- shell-script -*-
# vi: ft=sh
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
# #
# This file is part of systemd. # This file is part of systemd.
@ -103,21 +104,22 @@ __get_reloadable_units () {
} | sort -u ) } | sort -u )
} }
__get_failed_units () { __systemctl $1 list-units "$2*" \ __get_failed_units() { __systemctl $1 list-units "$2*" \
| { while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; }; } | while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; }
__get_enabled_units () { __systemctl $1 list-unit-files "$2*" \ __get_enabled_units() { __systemctl $1 list-unit-files "$2*" \
| { while read -r a b c ; do [[ $b == "enabled" ]] && echo " $a"; done; }; } | while read -r a b c ; do [[ $b == "enabled" ]] && echo " $a"; done; }
__get_disabled_units () { __systemctl $1 list-unit-files "$2*" \ __get_disabled_units() { __systemctl $1 list-unit-files "$2*" \
| { while read -r a b c ; do [[ $b == "disabled" ]] && echo " $a"; done; }; } | while read -r a b c ; do [[ $b == "disabled" ]] && echo " $a"; done; }
__get_masked_units () { __systemctl $1 list-unit-files "$2*" \ __get_masked_units() { __systemctl $1 list-unit-files "$2*" \
| { while read -r a b c ; do [[ $b == "masked" ]] && echo " $a"; done; }; } | while read -r a b c ; do [[ $b == "masked" ]] && echo " $a"; done; }
__get_all_unit_files () { { __systemctl $1 list-unit-files "$2*"; } | { while read -r a b; do echo " $a"; done; }; } __get_all_unit_files() { __systemctl $1 list-unit-files "$2*" | while read -r a b; do echo " $a"; done; }
__get_machines() { __get_machines() {
local a b local a
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \ while read a _; do
sort -u echo " $a"
done < <(machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null | sort -u; echo ".host")
} }
_systemctl () { _systemctl () {