From 1e58b1dc40a35d1b0fc8c3cef3ae3c3b7ac481fd Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 30 Mar 2018 17:06:50 +0900 Subject: [PATCH 1/3] bash-completion: busctl: suggests only writable properties for set-property --- shell-completion/bash/busctl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell-completion/bash/busctl b/shell-completion/bash/busctl index d077675a326..cfa4d4fa831 100644 --- a/shell-completion/bash/busctl +++ b/shell-completion/bash/busctl @@ -58,8 +58,9 @@ __get_members() { local path=$3 local interface=$4 local type=$5 + local flags=$6 local a b - busctl $mode introspect --list --no-legend --no-pager $busname $path $interface | sed -e 's/^\.//' | { while read a b c; do [[ "$b" == "$type" ]] && echo " $a"; done; }; + busctl $mode introspect --list --no-legend --no-pager $busname $path $interface | sed -e 's/^\.//' | { while read a b c d e; do [[ "$b" == "$type" && ( -z $flags || "$e" == "$flags" ) ]] && echo " $a"; done; }; } __get_signature() { @@ -176,7 +177,7 @@ _busctl() { elif [[ $n -eq 3 ]] ; then comps=$( __get_interfaces $mode ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]}) elif [[ $n -eq 4 ]] ; then - comps=$( __get_members $mode ${COMP_WORDS[COMP_CWORD-3]} ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]} property) + comps=$( __get_members $mode ${COMP_WORDS[COMP_CWORD-3]} ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]} property writable) elif [[ $n -eq 5 ]] ; then comps=$( __get_signature $mode ${COMP_WORDS[COMP_CWORD-4]} ${COMP_WORDS[COMP_CWORD-3]} ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]}) else From 4cbb7c500aa664452f45f8ec5a2b1f79a872eb2e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 30 Mar 2018 17:08:11 +0900 Subject: [PATCH 2/3] bash-completion: busctl: do not suggest "-" for signature Fixes #8371. --- shell-completion/bash/busctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell-completion/bash/busctl b/shell-completion/bash/busctl index cfa4d4fa831..c467b291b3f 100644 --- a/shell-completion/bash/busctl +++ b/shell-completion/bash/busctl @@ -70,7 +70,7 @@ __get_signature() { local interface=$4 local member=$5 local a b - busctl $mode introspect --list --no-legend --no-pager $busname $path $interface | sed -e 's/^\.//' | { while read a b c d; do [[ "$a" == "$member" ]] && echo " \"$c\""; done; }; + busctl $mode introspect --list --no-legend --no-pager $busname $path $interface | sed -e 's/^\.//' | { while read a b c d; do [[ "$a" == "$member" && "$c" != '-' ]] && echo " \"$c\""; done; }; } _busctl() { From 7f9c3ecad840fe8584ad4d350eefb67fe43869e7 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 30 Mar 2018 17:13:52 +0900 Subject: [PATCH 3/3] bash-completion: busctl: make variables local --- shell-completion/bash/busctl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell-completion/bash/busctl b/shell-completion/bash/busctl index c467b291b3f..c357c25bc32 100644 --- a/shell-completion/bash/busctl +++ b/shell-completion/bash/busctl @@ -48,7 +48,7 @@ __get_interfaces() { local mode=$1 local busname=$2 local path=$3 - local a b + local a b c busctl $mode introspect --list --no-legend --no-pager $busname $path | { while read a b c; do [[ "$b" == "interface" ]] && echo " $a"; done; }; } @@ -59,7 +59,7 @@ __get_members() { local interface=$4 local type=$5 local flags=$6 - local a b + local a b c d e busctl $mode introspect --list --no-legend --no-pager $busname $path $interface | sed -e 's/^\.//' | { while read a b c d e; do [[ "$b" == "$type" && ( -z $flags || "$e" == "$flags" ) ]] && echo " $a"; done; }; } @@ -69,12 +69,12 @@ __get_signature() { local path=$3 local interface=$4 local member=$5 - local a b + local a b c d busctl $mode introspect --list --no-legend --no-pager $busname $path $interface | sed -e 's/^\.//' | { while read a b c d; do [[ "$a" == "$member" && "$c" != '-' ]] && echo " \"$c\""; done; }; } _busctl() { - local i verb comps mode + local i n verb comps mode local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [STANDALONE]='-h --help --version --no-pager --no-legend --system --user