chiark / gitweb /
bash completion: fix __get_startable_units
[elogind.git] / shell-completion / bash / hostnamectl
index a57bffe15f7647525d2ac6ba04b2bd9c39d5898e..9c75da9e7f8b6f699f0d465d1563e9e10e514650 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
 }
 
 _hostnamectl() {
@@ -40,7 +41,7 @@ _hostnamectl() {
                       [NAME]='set-hostname'
         )
 
-        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