chiark / gitweb /
Updates in bash autocompletions
[elogind.git] / shell-completion / bash / timedatectl
index 2842b3106925d81fb470f670b1cd439a748792f6..a57fbd25466ffbd5479ddf25ea98f53c5121b309 100644 (file)
 # 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
 }
 
 _timedatectl() {
         local i verb comps
         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
         local OPTS='-h --help --version --adjust-system-clock --no-pager
-                    --no-ask-password -H --host'
+                    --no-ask-password -H --host --machine'
 
         if __contains_word "$prev" $OPTS; then
                 case $prev in
@@ -51,7 +52,7 @@ _timedatectl() {
                      [TIME]='set-time'
         )
 
-        for ((i=0; i <= COMP_CWORD; i++)); do
+        for ((i=0; i < COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
                         verb=${COMP_WORDS[i]}
                         break