From 05ebcbd5c54ffaa59ce6855b8cb9907ee4e43a86 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 4 Sep 2023 10:56:18 +0200 Subject: [PATCH] shell-completions: code cleanup --- shell-completion/bash/systemctl.in | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index 9c730846fc..adf60add23 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -1,4 +1,5 @@ # systemctl(1) completion -*- shell-script -*- +# vi: ft=sh # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is part of systemd. @@ -103,21 +104,22 @@ __get_reloadable_units () { } | sort -u ) } -__get_failed_units () { __systemctl $1 list-units "$2*" \ - | { while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; }; } -__get_enabled_units () { __systemctl $1 list-unit-files "$2*" \ - | { while read -r a b c ; do [[ $b == "enabled" ]] && echo " $a"; done; }; } -__get_disabled_units () { __systemctl $1 list-unit-files "$2*" \ - | { while read -r a b c ; do [[ $b == "disabled" ]] && echo " $a"; done; }; } -__get_masked_units () { __systemctl $1 list-unit-files "$2*" \ - | { 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_failed_units() { __systemctl $1 list-units "$2*" \ + | while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; } +__get_enabled_units() { __systemctl $1 list-unit-files "$2*" \ + | while read -r a b c ; do [[ $b == "enabled" ]] && echo " $a"; done; } +__get_disabled_units() { __systemctl $1 list-unit-files "$2*" \ + | while read -r a b c ; do [[ $b == "disabled" ]] && echo " $a"; done; } +__get_masked_units() { __systemctl $1 list-unit-files "$2*" \ + | 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_machines() { - local a b - { machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \ - { while read a b; do echo " $a"; done; } | \ - sort -u + local a + + while read a _; do + echo " $a" + done < <(machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null | sort -u; echo ".host") } _systemctl () {