|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
From f6441eaf050267c05ef8df8d5614bb598528942f Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
Date: Thu, 27 Jul 2017 20:22:54 +0900
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
Subject: [PATCH] bash-completion: use the first argument instead of the global
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
variable (#6457)
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
Without this fix:
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
$ systemctl start <tab>
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
Display all 135 possibilities? (y or n)
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
$ __get_startable_units --system | wc -l
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
224
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
the number of the suggestions are quite different, as __get_startable_units --system does
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
not filter already started units. With this fix,
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
$ systemctl start <tab>
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
Display all 135 possibilities? (y or n)
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
$ __get_startable_units --system | wc -l
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
123
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
$ __get_template_names --system | wc -l
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
12
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
the number of the suggestions matches one the function returns.
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
For consistency with the other internal functions, it should use the first argument
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
instead of the global variable $mode.
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
[zj: add commit message to make it sound like we know what we're doing]
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
(cherry picked from commit 6bda23dd6aaba50cf8e3e6024248cf736cc443ca)
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
---
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
shell-completion/bash/systemctl.in | 14 +++++++-------
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
1 file changed, 7 insertions(+), 7 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
index 0398d09d18..bde28efc3e 100644
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
--- a/shell-completion/bash/systemctl.in
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
+++ b/shell-completion/bash/systemctl.in
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
@@ -68,7 +68,7 @@ __filter_units_by_properties () {
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
done
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
for ((i=0; i < ${#units[*]}; i++)); do
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
for ((j=0; j < ${#conditions[*]}; j++)); do
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
- if [[ "${props[ i * ${#conditions[*]} + j]}" != "${conditions[j]}" ]]; then
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
+ if [[ "${props[i * ${#conditions[*]} + j]}" != "${conditions[j]}" ]]; then
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
break
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
fi
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
done
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
@@ -87,19 +87,19 @@ __get_active_units () { __systemctl $1 list-units \
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
| { while read -r a b; do echo " $a"; done; }; }
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
__get_startable_units () {
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
# find startable inactive units
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
- __filter_units_by_properties $mode ActiveState,CanStart inactive,yes $(
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
- { __systemctl $mode list-unit-files --state enabled,enabled-runtime,linked,linked-runtime,static,indirect,disabled,generated,transient | \
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
+ __filter_units_by_properties $1 ActiveState,CanStart inactive,yes $(
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
+ { __systemctl $1 list-unit-files --state enabled,enabled-runtime,linked,linked-runtime,static,indirect,disabled,generated,transient | \
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
{ while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; }
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
- __systemctl $mode list-units --state inactive,failed | \
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
+ __systemctl $1 list-units --state inactive,failed | \
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
{ while read -r a b c; do [[ $b == "loaded" ]] && echo " $a"; done; }
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
} | sort -u )
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
}
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
__get_restartable_units () {
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
# filter out masked and not-found
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
- __filter_units_by_property $mode CanStart yes $(
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
- __systemctl $mode list-unit-files --state enabled,disabled,static | \
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
+ __filter_units_by_property $1 CanStart yes $(
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
+ __systemctl $1 list-unit-files --state enabled,disabled,static | \
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
{ while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; }
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
- __systemctl $mode list-units | \
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
+ __systemctl $1 list-units | \
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
{ while read -r a b; do echo " $a"; done; } )
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
}
|
|
Zbigniew Jędrzejewski-Szmek |
27bd1b |
__get_failed_units () { __systemctl $1 list-units \
|