Use _init_completion() in completions/o*.

This commit is contained in:
Ville Skyttä 2011-04-20 22:56:30 +03:00
parent 66dd0b35a2
commit aef53c1160
3 changed files with 29 additions and 44 deletions

View File

@ -4,11 +4,10 @@ have iscsiadm || return
_iscsiadm() _iscsiadm()
{ {
local cur prev mode split=false local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
local split=false
_split_longopt && split=true _split_longopt && split=true
case $prev in case $prev in
@ -34,10 +33,9 @@ _iscsiadm()
$split && return 0 $split && return 0
local options local options
if [[ $COMP_CWORD -gt 1 ]] ; then if [[ $cword -gt 1 ]] ; then
mode=${COMP_WORDS[2]}
case $mode in case ${words[2]} in
discovery) discovery)
options='--help --version --debug --print --interface --type \ options='--help --version --debug --print --interface --type \
--portal --login --op --name --value' --portal --login --op --name --value'

View File

@ -14,10 +14,8 @@ _ldap_protocols()
_ldapsearch() _ldapsearch()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-h) -h)
@ -61,10 +59,8 @@ complete -F _ldapsearch ldapsearch
_ldapaddmodify() _ldapaddmodify()
{ {
local cur prev options local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-h) -h)
@ -86,9 +82,10 @@ _ldapaddmodify()
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
local options
options='-c -S -n -v -M -MM -d -D -W -w -y -h -H -p -P -O -I \ options='-c -S -n -v -M -MM -d -D -W -w -y -h -H -p -P -O -I \
-Q -U -R -x -X -Y -Z -ZZ -f' -Q -U -R -x -X -Y -Z -ZZ -f'
if [[ ${COMP_WORDS[0]} == ldapmodify ]]; then if [[ ${words[0]} == ldapmodify ]]; then
options+=" -a" options+=" -a"
fi fi
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
@ -98,10 +95,8 @@ complete -F _ldapaddmodify ldapadd ldapmodify
_ldapdelete() _ldapdelete()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-h) -h)
@ -131,10 +126,8 @@ complete -F _ldapdelete ldapdelete
_ldapcompare() _ldapcompare()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-h) -h)
@ -164,10 +157,8 @@ complete -F _ldapcompare ldapcompare
_ldapmodrdn() _ldapmodrdn()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-h) -h)
@ -197,10 +188,8 @@ complete -F _ldapmodrdn ldapmodrdn
_ldapwhoami() _ldapwhoami()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-h) -h)
@ -230,10 +219,8 @@ complete -F _ldapwhoami ldapwhoami
_ldappasswd() _ldappasswd()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-h) -h)

View File

@ -7,9 +7,9 @@ _openssl_sections()
local config f local config f
# check if a specific configuration file is used # check if a specific configuration file is used
for (( i=2; i < COMP_CWORD; i++ )); do for (( i=2; i < cword; i++ )); do
if [[ "${COMP_WORDS[i]}" == -config ]]; then if [[ "${words[i]}" == -config ]]; then
config=${COMP_WORDS[i+1]} config=${words[i+1]}
break break
fi fi
done done
@ -30,10 +30,10 @@ _openssl_sections()
_openssl() _openssl()
{ {
local cur prev commands command options formats local cur prev words cword
_init_completion || return
COMPREPLY=() local commands command options formats
_get_comp_words_by_ref cur prev
commands='asn1parse ca ciphers crl crl2pkcs7 dgst dh dhparam dsa \ commands='asn1parse ca ciphers crl crl2pkcs7 dgst dh dhparam dsa \
dsaparam ec ecparam enc engine errstr gendh gendsa genrsa \ dsaparam ec ecparam enc engine errstr gendh gendsa genrsa \
@ -50,10 +50,10 @@ _openssl()
rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \ rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \
rc4-40' rc4-40'
if [ $COMP_CWORD -eq 1 ]; then if [ $cword -eq 1 ]; then
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
else else
command=${COMP_WORDS[1]} command=${words[1]}
case $prev in case $prev in
-CA|-CAfile|-CAkey|-CAserial|-cert|-certfile|-config|-content| \ -CA|-CAfile|-CAkey|-CAserial|-cert|-certfile|-config|-content| \
-dcert|-dkey|-dhparam|-extfile|-in|-inkey|-kfile|-key|-keyout| \ -dcert|-dkey|-dhparam|-extfile|-in|-inkey|-kfile|-key|-keyout| \