diff options
Diffstat (limited to '')
-rw-r--r-- | completions/arp | 38 | ||||
-rw-r--r-- | completions/arping | 16 | ||||
-rw-r--r-- | completions/arpspoof | 16 |
3 files changed, 36 insertions, 34 deletions
diff --git a/completions/arp b/completions/arp index 922e800..3d1669a 100644 --- a/completions/arp +++ b/completions/arp @@ -1,43 +1,45 @@ -# arp(8) completion -*- shell-script -*- +# arp(8) completion -*- shell-script -*- -_arp() +_comp_cmd_arp() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return + local noargopts='!(-*|*[iApfHt]*)' + # shellcheck disable=SC2254 case $prev in - --device | -!(-*)i) - _available_interfaces -a + --device | -${noargopts}i) + _comp_compgen_available_interfaces -a return ;; - --protocol | -!(-*)[Ap]) + --protocol | -${noargopts}[Ap]) # TODO protocol/address family return ;; - --file | -!(-*)f) - _filedir + --file | -${noargopts}f) + _comp_compgen_filedir return ;; - --hw-type | -!(-*)[Ht]) + --hw-type | -${noargopts}[Ht]) # TODO: parse from --help output? - COMPREPLY=($(compgen -W 'ash ether ax25 netrom rose arcnet \ - dlci fddi hippi irda x25 eui64' -- "$cur")) + _comp_compgen -- -W 'ash ether ax25 netrom rose arcnet dlci fddi + hippi irda x25 eui64' return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help || _comp_compgen_usage return fi - local args - _count_args "" "@(--device|--protocol|--file|--hw-type|-!(-*)[iApfHt])" - case $args in + local REPLY + _comp_count_args -a "@(--device|--protocol|--file|--hw-type|-${noargopts}[iApfHt])" + case $REPLY in 1) local ips=$("$1" -an | command sed -ne \ 's/.*(\([0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}\)).*/\1/p') - COMPREPLY=($(compgen -W '$ips' -- "$cur")) + _comp_compgen -- -W '$ips' ;; 2) # TODO if -d mode: "pub"; if not -f mode: hw_addr @@ -54,6 +56,6 @@ _arp() ;; esac } && - complete -F _arp arp + complete -F _comp_cmd_arp arp # ex: filetype=sh diff --git a/completions/arping b/completions/arping index 57e1e19..c69fc2d 100644 --- a/completions/arping +++ b/completions/arping @@ -1,31 +1,31 @@ # arping(8) completion -*- shell-script -*- -_arping() +_comp_cmd_arping() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return case $prev in -*c | -*w) return ;; -*I) - _available_interfaces -a + _comp_compgen_available_interfaces -a return ;; -*s) - _ip_addresses + _comp_compgen_ip_addresses return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h return fi - _known_hosts_real -- "$cur" + _comp_compgen_known_hosts -- "$cur" } && - complete -F _arping arping + complete -F _comp_cmd_arping arping # ex: filetype=sh diff --git a/completions/arpspoof b/completions/arpspoof index d1a1373..8939f2d 100644 --- a/completions/arpspoof +++ b/completions/arpspoof @@ -1,28 +1,28 @@ # arpspoof completion -*- shell-script -*- -_arpspoof() +_comp_cmd_arpspoof() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return case $prev in -i) - _available_interfaces -a + _comp_compgen_available_interfaces -a return ;; -t) - _known_hosts_real -- "$cur" + _comp_compgen_known_hosts -- "$cur" return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage else - _known_hosts_real -- "$cur" + _comp_compgen_known_hosts -- "$cur" fi } && - complete -F _arpspoof arpspoof + complete -F _comp_cmd_arpspoof arpspoof # ex: filetype=sh |