Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
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 |