# iperf(1) completion -*- shell-script -*- proc _iperf { local cur prev words cword split _init_completion -s || return match $prev { with -h|--help|-v|--version|-i|--interval|-l|--len|-p|--port|-w|--window|\ -M|--mss|-b|--bandwidth|-n|--num|-t|--time|-L|--listenport|-P|\ --parallel|-T|--ttl|-Z|--linux-congestion return with -f|--format setglobal COMPREPLY = ''( $( compgen -W 'k m K M' -- "$cur" ) ) return with -o|--output|-F|--fileinput _filedir return with -B|--bind _available_interfaces -a _ip_addresses return with -c|--client _known_hosts_real $cur return with -x|--reportexclude setglobal COMPREPLY = ''( $( compgen -W 'C D M S V' -- "$cur" ) ) return with -y|--reportstyle setglobal COMPREPLY = ''( $( compgen -W 'C' -- "$cur" ) ) return } $split && return # Filter mode specific options local i filter=cat for i in [$(words[@])] { match $i { with -s|--server setglobal filter = ''sed -e /^Client.specific/,/^$/d'' with -c|--client setglobal filter = ''sed -e /^Server.specific/,/^$/d'' } } [[ $filter != cat ]] && setglobal filter = '' -e /--client/d -e /--server/d'' setglobal COMPREPLY = ''( $( compgen -W \ '$( "$1" --help 2>&1 | $filter | _parse_help - )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _iperf iperf # ex: ts=4 sw=4 et filetype=sh