r671 - /trunk/boinc/debian/extra/bash/boinc_cmd
fst-guest at users.alioth.debian.org
fst-guest at users.alioth.debian.org
Fri Jun 22 08:35:04 UTC 2007
Author: fst-guest
Date: Fri Jun 22 08:35:04 2007
New Revision: 671
URL: http://svn.debian.org/wsvn/pkg-boinc/?sc=1&rev=671
Log:
Improved bash completion for boinc_cmd.
Modified:
trunk/boinc/debian/extra/bash/boinc_cmd
Modified: trunk/boinc/debian/extra/bash/boinc_cmd
URL: http://svn.debian.org/wsvn/pkg-boinc/trunk/boinc/debian/extra/bash/boinc_cmd?rev=671&op=diff
==============================================================================
--- trunk/boinc/debian/extra/bash/boinc_cmd (original)
+++ trunk/boinc/debian/extra/bash/boinc_cmd Fri Jun 22 08:35:04 2007
@@ -1,16 +1,36 @@
_boinc_cmd()
{
- local cur prev opts
+ local cur prev opts cmds
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
- opts="$(boinc_cmd --help 2>&1 | sed -r 's/^[[:space:]](--[a-z_]*).*/\1/' | grep '^--')"
- if [[ "${cur}" == -* ]]; then
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ opts="--host --passwd -h --help -V --version"
+ cmds="$(boinc_cmd --help 2>&1 | sed -r 's/^[[:space:]](--[a-z_]*).*/\1/' \
+ | grep '^--')"
+
+ # The following if construct assures that:
+ # - no command follows if one of $opts or $cmds was given
+ # - after --host follows only one command or --passwd and one command
+ # - after --passwd follows only one command
+ if [[ $COMP_CWORD -eq 1 ]]; then
+ COMPREPLY=( $(compgen -W "$opts $cmds" -- "$cur") )
return 0
+ elif [[ "${COMP_WORDS[@]}" =~ ".* --passwd .*" ]]; then
+ if [[ "$prev" == --passwd ]]; then
+ return 0
+ elif [[ $COMP_CWORD -lt 6 ]]; then
+ COMPREPLY=( $(compgen -W "$cmds" -- "$cur") )
+ return 0
+ fi
+ elif [[ "${COMP_WORDS[@]}" =~ ".* --host .*" ]]; then
+ if [[ "$prev" == --host ]]; then
+ _known_hosts
+ elif [[ $COMP_CWORD -lt 4 ]]; then
+ COMPREPLY=( $(compgen -W "--passwd $cmds" -- "$cur") )
+ return 0
+ fi
fi
-
}
complete -F _boinc_cmd boinc_cmd
# vim: syntax=sh
More information about the pkg-boinc-commits
mailing list