summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2016-09-14 15:22:45 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2016-09-14 15:22:45 +0900
commitc07c80bc969fdb745593a86c8a34758722eeb29a (patch)
tree13a3205ef2010c71d4a552733b6f4225eb59d4f1
parentb1bdb6496c07fc4fcf3f0feae69b5ef89ae557d9 (diff)
bash-completion: systemctl: use local variables
-rw-r--r--shell-completion/bash/systemctl.in10
1 files changed, 3 insertions, 7 deletions
diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in
index e62cfa57a9..dcf71a1f51 100644
--- a/shell-completion/bash/systemctl.in
+++ b/shell-completion/bash/systemctl.in
@@ -41,7 +41,7 @@ __contains_word () {
__filter_units_by_property () {
local mode=$1 property=$2 value=$3 ; shift 3
local units=("$@")
- local props
+ local props i
IFS=$'\n' read -rd '' -a props < \
<(__systemctl $mode show --property "$property" -- "${units[@]}")
for ((i=0; $i < ${#units[*]}; i++)); do
@@ -54,12 +54,11 @@ __filter_units_by_property () {
__filter_units_by_properties () {
local mode=$1 properties=$2 values=$3 ; shift 3
local units=("$@")
- local props
+ local props i j conditions=()
IFS=$'\n' read -rd '' -a props < \
<(__systemctl $mode show --property "$properties" -- "${units[@]}")
IFS=$',' read -r -a properties < <(echo $properties)
IFS=$',' read -r -a values < <(echo $values)
- local conditions=()
for ((i=0; i < ${#properties[*]}; i++)); do
for ((j=0; j < ${#properties[*]}; j++)); do
if [[ ${props[i]%%=*} == ${properties[j]} ]]; then
@@ -67,16 +66,13 @@ __filter_units_by_properties () {
fi
done
done
- local flag
for ((i=0; i < ${#units[*]}; i++)); do
- flag=1
for ((j=0; j < ${#conditions[*]}; j++)); do
if [[ "${props[ i * ${#conditions[*]} + j]}" != "${conditions[j]}" ]]; then
- flag=
break
fi
done
- if [[ -n $flag ]]; then
+ if (( j == ${#conditions[*]} )); then
echo " ${units[i]}"
fi
done