Magellan Linux

Contents of /trunk/systemd/patches/systemd-37-systemctl-completion-always-invoke-with-no-legend.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1562 - (show annotations) (download)
Thu Nov 17 14:00:05 2011 UTC (12 years, 5 months ago) by niro
File size: 3485 byte(s)
fedora and upstream fixes
1 From 74eeab044e506a39786f484b160d9f64d48ad243 Mon Sep 17 00:00:00 2001
2 From: Dave Reisner <d@falconindy.com>
3 Date: Tue, 11 Oct 2011 20:56:53 -0400
4 Subject: [PATCH 5/5] systemctl-completion: always invoke with --no-legend
5
6 In the case of completion for the 'restart' verb, passing the invalid
7 unit name (the colums header) causes completion to cease functioning
8 entirely, with the error:
9
10 Failed to issue method call: Unit name UNIT is not valid.
11
12 This adds a small wrapper function for systemctl which can have common
13 options added to it.
14 ---
15 src/systemctl-bash-completion.sh | 20 ++++++++++++--------
16 1 files changed, 12 insertions(+), 8 deletions(-)
17
18 diff --git a/src/systemctl-bash-completion.sh b/src/systemctl-bash-completion.sh
19 index 6369a6c..6ebb792 100644
20 --- a/src/systemctl-bash-completion.sh
21 +++ b/src/systemctl-bash-completion.sh
22 @@ -15,6 +15,10 @@
23 # You should have received a copy of the GNU General Public License
24 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
25
26 +__systemctl() {
27 + systemctl --no-legend "$@"
28 +}
29 +
30 __contains_word () {
31 local word=$1; shift
32 for w in $*; do [[ $w = $word ]] && return 0; done
33 @@ -24,7 +28,7 @@ __contains_word () {
34 __filter_units_by_property () {
35 local property=$1 value=$2 ; shift ; shift
36 local -a units=( $* )
37 - local -a props=( $(systemctl show --property "$property" -- ${units[*]} | grep -v ^$) )
38 + local -a props=( $(__systemctl show --property "$property" -- ${units[*]} | grep -v ^$) )
39 for ((i=0; $i < ${#units[*]}; i++)); do
40 if [[ "${props[i]}" = "$property=$value" ]]; then
41 echo "${units[i]}"
42 @@ -32,10 +36,10 @@ __filter_units_by_property () {
43 done
44 }
45
46 -__get_all_units () { systemctl list-units --full --all | awk ' {print $1}' ; }
47 -__get_active_units () { systemctl list-units --full | awk ' {print $1}' ; }
48 -__get_inactive_units () { systemctl list-units --full --all | awk '$3 == "inactive" {print $1}' ; }
49 -__get_failed_units () { systemctl list-units --full | awk '$3 == "failed" {print $1}' ; }
50 +__get_all_units () { __systemctl list-units --full --all | awk ' {print $1}' ; }
51 +__get_active_units () { __systemctl list-units --full | awk ' {print $1}' ; }
52 +__get_inactive_units () { __systemctl list-units --full --all | awk '$3 == "inactive" {print $1}' ; }
53 +__get_failed_units () { __systemctl list-units --full | awk '$3 == "failed" {print $1}' ; }
54
55 _systemctl () {
56 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
57 @@ -134,13 +138,13 @@ _systemctl () {
58 comps=''
59
60 elif __contains_word "$verb" ${VERBS[JOBS]}; then
61 - comps=$( systemctl list-jobs | awk '{print $1}' )
62 + comps=$( __systemctl list-jobs | awk '{print $1}' )
63
64 elif __contains_word "$verb" ${VERBS[SNAPSHOTS]}; then
65 - comps=$( systemctl list-units --type snapshot --full --all | awk '{print $1}' )
66 + comps=$( __systemctl list-units --type snapshot --full --all | awk '{print $1}' )
67
68 elif __contains_word "$verb" ${VERBS[ENVS]}; then
69 - comps=$( systemctl show-environment | sed 's_\([^=]\+=\).*_\1_' )
70 + comps=$( __systemctl show-environment | sed 's_\([^=]\+=\).*_\1_' )
71 compopt -o nospace
72 fi
73
74 --
75 1.7.4.4
76