python/mach/bash-completion.sh

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 function _mach()
michael@0 2 {
michael@0 3 local cur cmds c subcommand
michael@0 4 COMPREPLY=()
michael@0 5
michael@0 6 # Load the list of commands
michael@0 7 cmds=`"${COMP_WORDS[0]}" mach-commands`
michael@0 8
michael@0 9 # Look for the subcommand.
michael@0 10 cur="${COMP_WORDS[COMP_CWORD]}"
michael@0 11 subcommand=""
michael@0 12 c=1
michael@0 13 while [ $c -lt $COMP_CWORD ]; do
michael@0 14 word="${COMP_WORDS[c]}"
michael@0 15 for cmd in $cmds; do
michael@0 16 if [ "$cmd" = "$word" ]; then
michael@0 17 subcommand="$word"
michael@0 18 fi
michael@0 19 done
michael@0 20 c=$((++c))
michael@0 21 done
michael@0 22
michael@0 23 if [[ "$subcommand" == "help" || -z "$subcommand" ]]; then
michael@0 24 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
michael@0 25 fi
michael@0 26
michael@0 27 return 0
michael@0 28 }
michael@0 29 complete -o default -F _mach mach

mercurial