| 1 |
_getopt_module() |
| 2 |
{ |
| 3 |
local cur prev OPTS |
| 4 |
COMPREPLY=() |
| 5 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 6 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 7 |
case $prev in |
| 8 |
'-l'|'--longoptions') |
| 9 |
COMPREPLY=( $(compgen -W "longopts" -- $cur) ) |
| 10 |
return 0 |
| 11 |
;; |
| 12 |
'-n'|'--name') |
| 13 |
COMPREPLY=( $(compgen -W "name" -- $cur) ) |
| 14 |
return 0 |
| 15 |
;; |
| 16 |
'-o'|'--options') |
| 17 |
COMPREPLY=( $(compgen -W "optstring" -- $cur) ) |
| 18 |
return 0 |
| 19 |
;; |
| 20 |
'-s'|'--shell') |
| 21 |
COMPREPLY=( $(compgen -W "sh bash csh tcsh" -- $cur) ) |
| 22 |
return 0 |
| 23 |
;; |
| 24 |
'-h'|'--help'|'-V'|'--version') |
| 25 |
return 0 |
| 26 |
;; |
| 27 |
esac |
| 28 |
case $cur in |
| 29 |
-*) |
| 30 |
OPTS="--alternative |
| 31 |
--help |
| 32 |
--longoptions |
| 33 |
--name |
| 34 |
--options |
| 35 |
--quiet |
| 36 |
--quiet-output |
| 37 |
--shell |
| 38 |
--test |
| 39 |
--unknown |
| 40 |
--unquoted |
| 41 |
--version" |
| 42 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 43 |
return 0 |
| 44 |
;; |
| 45 |
esac |
| 46 |
return 0 |
| 47 |
} |
| 48 |
complete -F _getopt_module getopt |