diff options
Diffstat (limited to 'completions/vpnc')
-rw-r--r-- | completions/vpnc | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/completions/vpnc b/completions/vpnc index bbdb8ee..79ffff3 100644 --- a/completions/vpnc +++ b/completions/vpnc @@ -1,82 +1,78 @@ # bash completion for vpnc -*- shell-script -*- -_vpnc() +_comp_cmd_vpnc() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return case $prev in - --help | --long-help | --version | --id | --username | --domain | --ifname | \ - --application-version | --local-addr | --local-port | --udp-port | --dpd-idle | \ - --target-network | --ifmtu) + --help | --long-help | --version | --id | --username | --domain | \ + --ifname | --application-version | --local-addr | --local-port | \ + --udp-port | --dpd-idle | --target-network | --ifmtu) return ;; --gateway) - _known_hosts_real -- "$cur" + _comp_compgen_known_hosts -- "$cur" return ;; --vendor) - COMPREPLY=($(compgen -W 'cisco netscreen' -- "$cur")) + _comp_compgen -- -W 'cisco netscreen' return ;; --natt-mode) - COMPREPLY=($(compgen -W 'natt none force-natt cisco-udp' \ - -- "$cur")) + _comp_compgen -- -W 'natt none force-natt cisco-udp' return ;; --script | --pid-file | --ca-file) - _filedir + _comp_compgen_filedir return ;; --dh) - COMPREPLY=($(compgen -W 'dh1 dh2 dh5' -- "$cur")) + _comp_compgen -- -W 'dh1 dh2 dh5' return ;; --pfs) - COMPREPLY=($(compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur")) + _comp_compgen -- -W 'nopfs dh1 dh2 dh5 server' return ;; --ifmode) - COMPREPLY=($(compgen -W 'tun tap' -- "$cur")) + _comp_compgen -- -W 'tun tap' return ;; --debug) - COMPREPLY=($(compgen -W '0 1 2 3 99' -- "$cur")) + _comp_compgen -- -W '0 1 2 3 99' return ;; --auth-mode) - COMPREPLY=($(compgen -W 'psk cert hybrid' -- "$cur")) + _comp_compgen -- -W 'psk cert hybrid' return ;; --ca-dir) - _filedir -d + _comp_compgen_filedir -d return ;; --password-helper) - compopt -o filenames - COMPREPLY=($(compgen -c -- "$cur")) + _comp_compgen_commands return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" --long-help)' -- "$cur")) - elif [[ $cur == */* ]]; then + _comp_compgen_help -- --long-help + elif _comp_looks_like_path "$cur"; then # explicit filename - _filedir conf + _comp_compgen_filedir conf else # config name, /etc/vpnc/<name>.conf - local IFS=$' \t\n' reset=$(shopt -p nullglob) - shopt -s nullglob - local -a configs=(/etc/vpnc/*.conf) - configs=("${configs[@]##*/}") - configs=("${configs[@]%.conf}") - $reset - IFS=$'\n' - compopt -o filenames - COMPREPLY=($(compgen -W '${configs[@]}' -- "$cur")) + local -a configs + if _comp_expand_glob configs '/etc/vpnc/*.conf'; then + configs=("${configs[@]##*/}") + configs=("${configs[@]%.conf}") + compopt -o filenames + _comp_compgen -- -W '"${configs[@]}"' + fi fi } && - complete -F _vpnc vpnc + complete -F _comp_cmd_vpnc vpnc # ex: filetype=sh |