]> git.notmuchmail.org Git - notmuch/commitdiff
bash-completion: Localize variables, use more consistent variable names
authorIngmar Vanhassel <ingmar@exherbo.org>
Thu, 19 Nov 2009 02:14:52 +0000 (03:14 +0100)
committerCarl Worth <cworth@cworth.org>
Thu, 19 Nov 2009 10:31:44 +0000 (11:31 +0100)
notmuch-completion.bash

index ff0a24d60cbfe5f095ba41dfdd6a07e270db2b86..fc2d13c1e1cd3f780ad9c3cc1891385c54275d28 100644 (file)
 
 _notmuch()
 {
 
 _notmuch()
 {
-    current="$2"
+    local current previous commands help_options
 
 
-    commands="setup new search show reply tag dump restore help"
+    previous=${COMP_WORDS[COMP_CWORD-1]}
+    current="${COMP_WORDS[COMP_CWORD]}"
 
 
+    commands="setup new search show reply tag dump restore help"
     help_options="setup new search show reply tag dump restore search-terms"
 
     COMPREPLY=()
     help_options="setup new search show reply tag dump restore search-terms"
 
     COMPREPLY=()
-    prev=${COMP_WORDS[COMP_CWORD-1]}
 
     if [[ "$COMP_CWORD" == "1" ]]; then
         COMPREPLY=( $(compgen -W "${commands}" -- ${current}) )
     fi
 
 
     if [[ "$COMP_CWORD" == "1" ]]; then
         COMPREPLY=( $(compgen -W "${commands}" -- ${current}) )
     fi
 
-    if [[ $prev = "help" && "$COMP_CWORD" == "2" ]]; then
+    if [[ $previous = "help" && "$COMP_CWORD" == "2" ]]; then
         COMPREPLY=( $(compgen -W "${help_options}" -- ${current}) )
     fi
 }
         COMPREPLY=( $(compgen -W "${help_options}" -- ${current}) )
     fi
 }