title: How to pop item from array in bash completion shell script?
body: <p>I'm learning about bash completion. Here is my code:</p>
  
  <pre><code>_foo()
  {
         local cur prev opts
                 COMPREPLY=()
                 cur="${COMP_WORDS[COMP_CWORD]}"
                 prev="${COMP_WORDS[COMP_CWORD-1]}"
                 opts="push pull"
                      case "${prev}" in
                          push)
                              COMPREPLY=( $(compgen -W "--file --key" -- ${cur}) )
                              return 0
                              ;;
                          pull)
                              COMPREPLY=( $(compgen -W "--data --url" -- ${cur}) )
                              return 0
                              ;;
                          esac
        if [[ $COMP_CWORD == 1 ]] ; then
            COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
        fi
                return 0
  }
  complete -o default -F _foo foo
  </code></pre>
  
  <p>I want to know, How to pop item from array after it's used? Let me explain with example. This code work as follow:</p>
  
  <pre><code>$ foo [TAB]
  $ foo pu [TAB]
  push pull
  $ foo push [TAB]
  $ foo push -- [TAB]
  --file --key
  $ foo push --file [TAB]
  content of PWD
  </code></pre>
  
  <p>Since I used <strong><em>--file</em></strong> as argument, Next time it should not be shown as available arguments. It means if I do like this</p>
  
  <pre><code>$ foo push --file file.txt [TAB]
  --key ##It should be display as output
  </code></pre>
  
  <p>can anyone tell me, How can I do this? Thanks.</p>