chiark / gitweb /
shell-completion: busctl
[elogind.git] / shell-completion / bash / loginctl
index 1844085d49ee76a49a1e28570a2e424040f349e7..b0816a3b868ed39a29412f211d7b9fcd05aa1549 100644 (file)
 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
 __contains_word () {
 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
 __contains_word () {
-        local word=$1; shift
-        for w in $*; do [[ $w = $word ]] && return 0; done
-        return 1
+        local w word=$1; shift
+        for w in "$@"; do
+                [[ $w = "$word" ]] && return
+        done
 }
 
 __get_all_sessions () { loginctl list-sessions | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
 }
 
 __get_all_sessions () { loginctl list-sessions | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
@@ -69,7 +70,7 @@ _loginctl () {
                 [ATTACH]='attach'
         )
 
                 [ATTACH]='attach'
         )
 
-        for ((i=0; $i <= $COMP_CWORD; i++)); do
+        for ((i=0; i <= COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
                         verb=${COMP_WORDS[i]}
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
                         verb=${COMP_WORDS[i]}