summaryrefslogtreecommitdiffstats
path: root/completions/ip
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--completions/ip217
-rw-r--r--completions/ipcalc10
-rw-r--r--completions/iperf75
-rw-r--r--completions/ipmitool104
-rw-r--r--completions/ipsec71
-rw-r--r--completions/iptables56
-rw-r--r--completions/ipv6calc27
7 files changed, 303 insertions, 257 deletions
diff --git a/completions/ip b/completions/ip
index 12ad9aa..511f206 100644
--- a/completions/ip
+++ b/completions/ip
@@ -1,58 +1,78 @@
# ip(8) completion -*- shell-script -*-
-_iproute2_etc()
+_comp_cmd_ip__iproute2_etc()
{
- COMPREPLY+=($(compgen -W \
- "$(awk '!/#/ { print $2 }' /etc/iproute2/$1 2>/dev/null)" \
- -- "$cur"))
+ _comp_compgen -a split -- "$(_comp_awk '!/#/ { print $2 }' "/etc/iproute2/$1" \
+ 2>/dev/null)"
}
-_ip()
+_comp_cmd_ip__netns()
{
- local cur prev words cword
- _init_completion || return
+ _comp_compgen_split -- "$(
+ {
+ ${1-ip} -c=never netns list 2>/dev/null || ${1-ip} netns list
+ } | _comp_awk '{print $1}'
+ )"
+}
+
+_comp_cmd_ip()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
- -V | -Version | -rc | -rcvbuf)
+ -V | -Version | -rc | -rcvbuf | -l | -loops)
return
;;
-f | -family)
- COMPREPLY=($(compgen -W 'inet inet6 ipx dnet link' -- "$cur"))
+ _comp_compgen -- -W 'inet inet6 ipx dnet link'
return
;;
-b | -batch)
- _filedir
+ _comp_compgen_filedir
+ return
+ ;;
+ -n | -netns)
+ _comp_cmd_ip__netns "$1"
return
;;
-force)
- COMPREPLY=($(compgen -W '-batch' -- "$cur"))
+ _comp_compgen -- -W '-batch'
return
;;
esac
- local subcword cmd subcmd=""
- for ((subcword = 1; subcword < ${#words[@]} - 1; subcword++)); do
+ local subcword cmd="" has_cmd="" subcmd=""
+ for ((subcword = 1; subcword < cword; subcword++)); do
[[ ${words[subcword]} == -b?(atch) ]] && return
- [[ -v cmd ]] && subcmd=${words[subcword]} && break
- [[ ${words[subcword]} != -* && \
- ${words[subcword - 1]} != -@(f?(amily)|rc?(vbuf)) ]] &&
- cmd=${words[subcword]}
+ [[ $has_cmd ]] && subcmd=${words[subcword]} && break
+ [[ ${words[subcword]} != -* &&
+ ${words[subcword - 1]} != -@(f?(amily)|rc?(vbuf)) ]] &&
+ cmd=${words[subcword]} has_cmd=set
done
- if [[ ! -v cmd ]]; then
+ if [[ ! $has_cmd ]]; then
case $cur in
-*)
- local c="-Version -statistics -details -resolve -family
- -oneline -timestamp -batch -rcvbuf"
- ((cword == 1)) && c+=" -force"
- COMPREPLY=($(compgen -W "$c" -- "$cur"))
+ _comp_compgen -a help - <<<"$(
+ ((cword == 1)) && printf '%s\n' -force
+ {
+ "$1" -c=never help || "$1" help
+ } 2>&1 | command sed -e \
+ 's/[{|}=]/\n/g' -e \
+ 's/\[\([^]]\{1,\}\)\]/\1/g'
+ )"
;;
*)
- COMPREPLY=($(compgen -W "help $($1 help 2>&1 | command sed -e \
- '/OBJECT := /,/}/!d' -e \
- 's/.*{//' -e \
- 's/}.*//' -e \
- 's/|//g')" -- "$cur"))
+ _comp_compgen_split -- "help $(
+ {
+ $1 -c=never help || $1 help
+ } 2>&1 | command sed -e \
+ '/OBJECT := /,/}/!d' -e \
+ 's/.*{//' -e \
+ 's/}.*//' -e \
+ 's/|//g'
+ )"
;;
esac
return
@@ -69,26 +89,26 @@ _ip()
delete)
case $((cword - subcword)) in
1)
- _available_interfaces
+ _comp_compgen_available_interfaces
;;
2)
- COMPREPLY=($(compgen -W 'type' -- "$cur"))
+ _comp_compgen -- -W 'type'
;;
3)
[[ $prev == type ]] &&
- COMPREPLY=($(compgen -W 'vlan veth vcan dummy
- ifb macvlan can' -- "$cur"))
+ _comp_compgen -- -W 'vlan veth vcan dummy ifb
+ macvlan can'
;;
esac
;;
set)
if ((cword - subcword == 1)); then
- _available_interfaces
+ _comp_compgen_available_interfaces
else
case $prev in
arp | dynamic | multicast | allmulticast | promisc | \
trailers)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
;;
txqueuelen | name | address | broadcast | mtu | netns | alias) ;;
@@ -97,25 +117,24 @@ _ip()
promisc trailers txqueuelen name address
broadcast mtu netns alias"
[[ $prev != @(up|down) ]] && c+=" up down"
- COMPREPLY=($(compgen -W "$c" -- "$cur"))
+ _comp_compgen -- -W "$c"
;;
esac
fi
;;
show)
if ((cword == subcword + 1)); then
- _available_interfaces
- COMPREPLY+=($(compgen -W 'dev group up' -- "$cur"))
+ _comp_compgen_available_interfaces
+ _comp_compgen -a -- -W 'dev group up'
elif [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
elif [[ $prev == group ]]; then
- _iproute2_etc group
+ _comp_cmd_ip__iproute2_etc group
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add delete set show' \
- -- "$cur"))
+ _comp_compgen -- -W 'help add delete set show'
;;
esac
;;
@@ -124,38 +143,38 @@ _ip()
case $subcmd in
add | change | replace)
if [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
elif [[ $prev == scope ]]; then
- _iproute2_etc rt_scopes
+ _comp_cmd_ip__iproute2_etc rt_scopes
else
: # TODO
fi
;;
del)
if [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
elif [[ $prev == scope ]]; then
- _iproute2_etc rt_scopes
+ _comp_cmd_ip__iproute2_etc rt_scopes
else
: # TODO
fi
;;
show | flush)
if ((cword == subcword + 1)); then
- _available_interfaces
- COMPREPLY+=($(compgen -W 'dev scope to label dynamic
+ _comp_compgen_available_interfaces
+ _comp_compgen -a -- -W 'dev scope to label dynamic
permanent tentative deprecated dadfailed temporary
- primary secondary up' -- "$cur"))
+ primary secondary up'
elif [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
elif [[ $prev == scope ]]; then
- _iproute2_etc rt_scopes
+ _comp_cmd_ip__iproute2_etc rt_scopes
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add change replace del
- show flush' -- "$cur"))
+ _comp_compgen -- -W 'help add change replace del show
+ flush'
;;
esac
;;
@@ -164,15 +183,14 @@ _ip()
case $subcmd in
list | add | del | flush)
if [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
else
: # TODO
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help list add del flush' \
- -- "$cur"))
+ _comp_compgen -- -W 'help list add del flush'
;;
esac
;;
@@ -181,7 +199,7 @@ _ip()
case $subcmd in
list | flush)
if [[ $prev == proto ]]; then
- _iproute2_etc rt_protos
+ _comp_cmd_ip__iproute2_etc rt_protos
else
: # TODO
fi
@@ -189,25 +207,32 @@ _ip()
get)
# TODO
;;
- a | add | d | del | change | append | r | replace | monitor)
+ a | add | d | del | change | append | r | replace)
if [[ $prev == via ]]; then
- COMPREPLY=($(compgen -W "$($1 r | command sed -ne \
- 's/.*via \([0-9.]*\).*/\1/p')" -- "$cur"))
+ _comp_compgen_split -- "$(
+ {
+ $1 -c=never r 2>/dev/null || $1 r
+ } | command sed -ne \
+ 's/.*via \([0-9.]*\).*/\1/p'
+ )"
elif [[ $prev == "$subcmd" ]]; then
- COMPREPLY=($(compgen -W "table default \
- $($1 r | cut -d ' ' -f 1)" -- "$cur"))
+ _comp_compgen_split -- "table default $(
+ {
+ $1 -c=never r 2>/dev/null || $1 r
+ } | cut -d ' ' -f 1
+ )"
elif [[ $prev == dev ]]; then
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
elif [[ $prev == table ]]; then
- COMPREPLY=($(compgen -W 'local main default' -- "$cur"))
+ _comp_compgen -- -W 'local main default'
else
- COMPREPLY=($(compgen -W 'via dev weight' -- "$cur"))
+ _comp_compgen -- -W 'via dev weight'
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help list flush get add del
- change append replace monitor' -- "$cur"))
+ _comp_compgen -- -W 'help list flush get add del change
+ append replace'
;;
esac
;;
@@ -221,16 +246,16 @@ _ip()
suppress_ifgroup | realms | nat | goto) ;;
iif | oif)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
;;
table | lookup)
- COMPREPLY=($(compgen -W 'local main default' -- "$cur"))
+ _comp_compgen -- -W 'local main default'
;;
*)
- COMPREPLY=($(compgen -W 'from to tos dsfield fwmark
- uidrange ipproto sport dport priority table lookup
- protocol suppress_prefixlength suppress_ifgroup realms
- nat goto iif oif not' -- "$cur"))
+ _comp_compgen -- -W 'from to tos dsfield fwmark
+ uidrange ipproto sport dport priority table
+ lookup protocol suppress_prefixlength
+ suppress_ifgroup realms nat goto iif oif not'
;;
esac
;;
@@ -238,14 +263,14 @@ _ip()
if [[ $prev == protocol ]]; then
:
else
- COMPREPLY=($(compgen -W 'protocol' -- "$cur"))
+ _comp_compgen -- -W 'protocol'
fi
;;
restore | show) ;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add del list flush save
- restore show' -- "$cur"))
+ _comp_compgen -- -W 'help add del list flush save
+ restore show'
;;
esac
;;
@@ -260,8 +285,8 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add del change replace
- show flush' -- "$cur"))
+ _comp_compgen -- -W 'help add del change replace show
+ flush'
;;
esac
;;
@@ -276,8 +301,7 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help change show' \
- -- "$cur"))
+ _comp_compgen -- -W 'help change show'
;;
esac
;;
@@ -291,8 +315,7 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add change del show prl
- 6rd' -- "$cur"))
+ _comp_compgen -- -W 'help add change del show prl 6rd'
;;
esac
;;
@@ -304,16 +327,15 @@ _ip()
;;
show)
if [[ $cword -eq $subcword+1 || $prev == dev ]]; then
- _available_interfaces
- [[ $prev != dev ]] &&
- COMPREPLY=($(compgen -W '${COMPREPLY[@]} dev' \
- -- "$cur"))
+ _comp_compgen_available_interfaces
+ if [[ $prev != dev ]]; then
+ _comp_compgen -a -W dev
+ fi
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add del show' \
- -- "$cur"))
+ _comp_compgen -- -W 'help add del show'
;;
esac
;;
@@ -325,7 +347,7 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help show' -- "$cur"))
+ _comp_compgen -- -W 'help show'
;;
esac
;;
@@ -335,7 +357,14 @@ _ip()
all) ;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help all' -- "$cur"))
+ _comp_compgen_split -- "help all $(
+ {
+ "$1" -c=never monitor help || "$1" monitor help
+ } 2>&1 | command sed -e \
+ '/OBJECTS := /,/[^|]$/!d' -e \
+ 's/OBJECTS := *//' -e \
+ 's/|//g'
+ )"
;;
esac
;;
@@ -348,13 +377,12 @@ _ip()
# TODO
;;
delete | exec | pids | set)
- [[ $prev == "$subcmd" ]] &&
- COMPREPLY=($(compgen -W "$($1 netns list)" -- "$cur"))
+ [[ $prev == "$subcmd" ]] && _comp_cmd_ip__netns "$1"
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add delete exec
- identify list list-id monitor pids set' -- "$cur"))
+ _comp_compgen -- -W 'help add delete exec identify list
+ list-id monitor pids set'
;;
esac
;;
@@ -366,13 +394,12 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'state policy monitor' \
- -- "$cur"))
+ _comp_compgen -- -W 'state policy monitor'
;;
esac
;;
esac
} &&
- complete -F _ip ip
+ complete -F _comp_cmd_ip ip
# ex: filetype=sh
diff --git a/completions/ipcalc b/completions/ipcalc
index 5603c26..979a8c2 100644
--- a/completions/ipcalc
+++ b/completions/ipcalc
@@ -1,9 +1,9 @@
# ipcalc(1) completion -*- shell-script -*-
-_ipcalc()
+_comp_cmd_ipcalc()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --version | --split | -[hs])
@@ -18,8 +18,8 @@ _ipcalc()
done
[[ $cur != -* ]] ||
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _ipcalc ipcalc
+ complete -F _comp_cmd_ipcalc ipcalc
# ex: filetype=sh
diff --git a/completions/iperf b/completions/iperf
index 6347fe0..0168814 100644
--- a/completions/iperf
+++ b/completions/iperf
@@ -1,69 +1,90 @@
# iperf(1) completion -*- shell-script -*-
-_iperf()
+_comp_cmd_iperf()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
+ local noargopts='!(-*|*[ilpwMXbntLPTZCkOSAfIoFBcxy]*)'
+ # shellcheck disable=SC2254
case $prev in
--help | --version | --interval | --len | --port | --window | --mss | --bandwidth | \
--num | --time | --listenport | --parallel | --ttl | --linux-congestion | --omit | \
--congestion | --bytes | --blockcount | --cport | --set-mss | --flowlabel | \
- --title | --tos | --affinity | -!(-*)[hvilpwMbntLPTZCkOSA])
+ --title | --tos | --affinity | --rcv-timeout | --server-bitrate-limit | \
+ --idle-timeout | --time-skew-threshold | --xbind | --nstreams | --connect-timeout | \
+ --bitrate | --pacing-timer | --fq-rate | --length | --dscp | --extra-data | \
+ --username | -${noargopts}[hvilpwMXbntLPTZCkOSA])
return
;;
- --format | -!(-*)f)
- COMPREPLY=($(compgen -W 'k m g K M G' -- "$cur"))
+ --format | -${noargopts}f)
+ local formats=$(
+ "$1" --help 2>&1 |
+ command sed -ne 's/^.*--format .*\[\([a-zA-Z]\{1,\}\)\].*/\1/p' |
+ command sed -e 's/./& /g'
+ )
+ _comp_compgen -- -W '$formats'
return
;;
- --output | --fileinput | -!(-*)[oF])
- _filedir
+ --pidfile | -${noargopts}I)
+ _comp_compgen_filedir pid
return
;;
- --bind | -!(-*)B)
- _available_interfaces -a
- _ip_addresses -a
- __ltrim_colon_completions "$cur"
+ --output | --fileinput | --authorized-users-path | -${noargopts}[oF])
+ _comp_compgen_filedir
return
;;
- --client | -!(-*)c)
- _known_hosts_real -- "$cur"
+ --bind | -${noargopts}B)
+ _comp_compgen_available_interfaces -a
+ _comp_compgen -a ip_addresses -a
return
;;
- --reportexclude | -!(-*)x)
- COMPREPLY=($(compgen -W 'C D M S V' -- "$cur"))
+ --bind-dev)
+ _comp_compgen_available_interfaces -a
return
;;
- --reportstyle | -!(-*)y)
- COMPREPLY=($(compgen -W 'C' -- "$cur"))
+ --client | -${noargopts}c)
+ _comp_compgen_known_hosts -- "$cur"
+ return
+ ;;
+ --reportexclude | -${noargopts}x)
+ _comp_compgen -- -W 'C D M S V'
+ return
+ ;;
+ --reportstyle | -${noargopts}y)
+ _comp_compgen -- -W 'C'
return
;;
--logfile)
- _filedir log
+ _comp_compgen_filedir log
+ return
+ ;;
+ --rsa-private-key-path | --rsa-public-key-path)
+ _comp_compgen_filedir pem
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
# Filter mode specific options
- local i filter=cat
+ local -a filter=(cat)
+ local i
for i in "${words[@]}"; do
case $i in
-s | --server)
- filter='command sed -e /^Client.specific/,/^\(Server.specific.*\)\?$/d'
+ filter=(command sed -e '/^Client.specific/,/^\(Server.specific.*\)\{0,1\}$/d')
;;
-c | --client)
- filter='command sed -e /^Server.specific/,/^\(Client.specific.*\)\?$/d'
+ filter=(command sed -e '/^Server.specific/,/^\(Client.specific.*\)\{0,1\}$/d')
;;
esac
done
- [[ $filter != cat ]] && filter+=' -e /--client/d -e /--server/d'
+ [[ $filter != cat ]] && filter+=(-e '/--client/d' -e '/--server/d')
- COMPREPLY=($(compgen -W \
- '$("$1" --help 2>&1 | $filter | _parse_help -)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" --help 2>&1 | "${filter[@]}")"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _iperf iperf iperf3
+ complete -F _comp_cmd_iperf iperf iperf3
# ex: filetype=sh
diff --git a/completions/ipmitool b/completions/ipmitool
index 920287d..5d6c212 100644
--- a/completions/ipmitool
+++ b/completions/ipmitool
@@ -1,65 +1,61 @@
# bash completion for ipmitool -*- shell-script -*-
-_ipmitool_singleline_help()
+_comp_cmd_ipmitool__singleline_help()
{
- COMPREPLY=($(compgen -W "$($1 $2 2>&1 |
- command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" "$2" 2>&1 |
+ command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')"
}
-_ipmitool()
+_comp_cmd_ipmitool()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[hVpUekyPmbtBTl])
return
;;
-*d)
- COMPREPLY=($(compgen -W "$(
- command ls -d /dev/ipmi* /dev/ipmi/* /dev/ipmidev/* \
- 2>/dev/null | command sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p'
- )" \
- -- "$cur"))
+ local -a files
+ _comp_expand_glob files '/dev/ipmi* /dev/ipmi/* /dev/ipmidev/*' &&
+ _comp_compgen -- -W '"${files[@]##*([^0-9])}"' -X '![0-9]*'
return
;;
-*I)
- COMPREPLY=($(compgen -W "$($1 -h 2>&1 |
+ _comp_compgen_split -- "$("$1" -h 2>&1 |
command sed -e '/^Interfaces:/,/^[[:space:]]*$/!d' \
- -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p')" \
- -- "$cur"))
+ -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p')"
return
;;
-*H)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*[fSO])
- _filedir
+ _comp_compgen_filedir
return
;;
-*C)
- COMPREPLY=($(compgen -W '{0..14}' -- "$cur"))
+ _comp_compgen -- -W '{0..14}'
return
;;
-*L)
- COMPREPLY=($(compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \
- -- "$cur"))
+ _comp_compgen -- -W 'CALLBACK USER OPERATOR ADMINISTRATOR'
return
;;
-*A)
- COMPREPLY=($(compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur"))
+ _comp_compgen -- -W 'NONE PASSWORD MD2 MD5 OEM'
return
;;
-*o)
- COMPREPLY=($(compgen -W "$($1 -o list 2>&1 |
- awk '/^[ \t]+/ { print $1 }') list" -- "$cur"))
+ _comp_compgen_split -- "$("$1" -o list 2>&1 |
+ _comp_awk '/^[ \t]+/ { print $1 }') list"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
return
fi
@@ -68,16 +64,16 @@ _ipmitool()
local cmds=(raw i2c spd lan chassis power event mc sdr sensor fru gendev
sel pef sol tsol isol user channel session sunoem kontronoem picmg fwum
firewall shell exec set hpm ekanalyzer)
- local i c cmd subcmd
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
- [[ -v cmd ]] && subcmd=${words[i]} && break
+ local i c cmd="" has_cmd="" subcmd
+ for ((i = 1; i < cword; i++)); do
+ [[ $has_cmd ]] && subcmd=${words[i]} && break
for c in "${cmds[@]}"; do
- [[ ${words[i]} == "$c" ]] && cmd=$c && break
+ [[ ${words[i]} == "$c" ]] && cmd=$c has_cmd=set && break
done
done
- if [[ ! -v cmd ]]; then
- COMPREPLY=($(compgen -W '${cmds[@]}' -- "$cur"))
+ if [[ ! $has_cmd ]]; then
+ _comp_compgen -- -W '"${cmds[@]}"'
return
fi
@@ -87,13 +83,12 @@ _ipmitool()
shell) ;;
- \
- exec)
- _filedir
+ exec)
+ _comp_compgen_filedir
;;
chassis | power | kontronoem | fwum)
- _ipmitool_singleline_help $1 $cmd
+ _comp_cmd_ipmitool__singleline_help "$1" "$cmd"
;;
lan)
@@ -102,15 +97,14 @@ _ipmitool()
alert)
[[ $prev == alert ]] &&
- COMPREPLY=($(compgen -W 'print set' -- "$cur"))
+ _comp_compgen -- -W 'print set'
;;
stats)
[[ $prev == stats ]] &&
- COMPREPLY=($(compgen -W 'print set' -- "$cur"))
+ _comp_compgen -- -W 'print set'
;;
*)
- COMPREPLY=($(compgen -W 'print set alert stats' \
- -- "$cur"))
+ _comp_compgen -- -W 'print set alert stats'
;;
esac
;;
@@ -120,25 +114,25 @@ _ipmitool()
get | info | type | list | entity) ;;
elist)
- COMPREPLY=($(compgen -W 'all full compact event mclog fru
- generic' -- "$cur"))
+ _comp_compgen -- -W 'all full compact event mclog fru
+ generic'
;;
dump)
- _filedir
+ _comp_compgen_filedir
;;
fill)
case $prev in
fill)
- COMPREPLY=($(compgen -W 'sensors file' -- "$cur"))
+ _comp_compgen -- -W 'sensors file'
;;
file)
- _filedir
+ _comp_compgen_filedir
;;
esac
;;
*)
- COMPREPLY=($(compgen -W 'get info type list elist entity
- dump fill' -- "$cur"))
+ _comp_compgen -- -W 'get info type list elist entity dump
+ fill'
;;
esac
;;
@@ -148,7 +142,7 @@ _ipmitool()
list | get | thresh) ;;
*)
- COMPREPLY=($(compgen -W 'list get thresh' -- "$cur"))
+ _comp_compgen -- -W 'list get thresh'
;;
esac
;;
@@ -158,15 +152,15 @@ _ipmitool()
info | clear | list | elist | delete) ;;
add | save | writeraw | readraw)
- _filedir
+ _comp_compgen_filedir
;;
time)
[[ $prev == time ]] &&
- COMPREPLY=($(compgen -W 'get set' -- "$cur"))
+ _comp_compgen -- -W 'get set'
;;
*)
- COMPREPLY=($(compgen -W 'info clear list elist delete add
- get save writeraw readraw time' -- "$cur"))
+ _comp_compgen -- -W 'info clear list elist delete add get
+ save writeraw readraw time'
;;
esac
;;
@@ -177,23 +171,23 @@ _ipmitool()
set)
[[ $prev == set ]] &&
- COMPREPLY=($(compgen -W 'name password' -- "$cur"))
+ _comp_compgen -- -W 'name password'
;;
*)
- COMPREPLY=($(compgen -W 'summary list set disable enable
- priv test' -- "$cur"))
+ _comp_compgen -- -W 'summary list set disable enable priv
+ test'
;;
esac
;;
set)
[[ $prev == set ]] &&
- COMPREPLY=($(compgen -W 'hostname username password privlvl
- authtype localaddr targetaddr port csv verbose' -- "$cur"))
+ _comp_compgen -- -W 'hostname username password privlvl
+ authtype localaddr targetaddr port csv verbose'
;;
esac
} &&
- complete -F _ipmitool ipmitool
+ complete -F _comp_cmd_ipmitool ipmitool
# ex: filetype=sh
diff --git a/completions/ipsec b/completions/ipsec
index 4bc8cdf..6bd4ebf 100644
--- a/completions/ipsec
+++ b/completions/ipsec
@@ -3,87 +3,86 @@
# Complete ipsec.conf conn entries.
#
# Reads a file from stdin in the ipsec.conf(5) format.
-_ipsec_connections()
+_comp_cmd_ipsec__connections()
{
local keyword name
while read -r keyword name; do
if [[ $keyword == [#]* ]]; then continue; fi
[[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=("$name")
done
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}"'
}
-_ipsec_freeswan()
+_comp_cmd_ipsec__freeswan()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'auto barf eroute klipsdebug look manual
- pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp
- tncfg whack' -- "$cur"))
+ _comp_compgen -- -W 'auto barf eroute klipsdebug look manual pluto
+ ranbits rsasigkey setup showdefaults showhostkey spi spigrp tncfg
+ whack'
return
fi
case ${words[1]} in
auto)
- COMPREPLY=($(compgen -W '--asynchronous --up --add --delete
- --replace --down --route --unroute --ready --status
- --rereadsecrets' -- "$cur"))
+ _comp_compgen -- -W '--asynchronous --up --add --delete --replace
+ --down --route --unroute --ready --status --rereadsecrets'
;;
manual)
- COMPREPLY=($(compgen -W '--up --down --route --unroute --union' \
- -- "$cur"))
+ _comp_compgen -- -W '--up --down --route --unroute --union'
;;
ranbits)
- COMPREPLY=($(compgen -W '--quick --continuous --bytes' -- "$cur"))
+ _comp_compgen -- -W '--quick --continuous --bytes'
;;
setup)
- COMPREPLY=($(compgen -W '--start --stop --restart' -- "$cur"))
+ _comp_compgen -- -W '--start --stop --restart'
;;
*) ;;
esac
}
-_ipsec_strongswan()
+_comp_cmd_ipsec__strongswan()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'down irdumm leases listaacerts listacerts
- listalgs listall listcacerts listcainfos listcards listcerts
- listcrls listgroups listocsp listocspcerts listpubkeys openac pki
- pluto pool purgecerts purgecrls purgeike purgeocsp ready reload
- rereadaacerts rereadacerts rereadall rereadcacerts rereadcrls
- rereadgroups rereadocspcerts rereadsecrets restart route scdecrypt
- scencrypt scepclient secrets start starter status statusall stop
- stroke unroute uci up update version whack --confdir --copyright
- --directory --help --version --versioncode' -- "$cur"))
+ _comp_compgen -- -W 'down irdumm leases listaacerts listacerts listalgs
+ listall listcacerts listcainfos listcards listcerts listcrls
+ listgroups listocsp listocspcerts listpubkeys openac pki pluto pool
+ purgecerts purgecrls purgeike purgeocsp ready reload rereadaacerts
+ rereadacerts rereadall rereadcacerts rereadcrls rereadgroups
+ rereadocspcerts rereadsecrets restart route scdecrypt scencrypt
+ scepclient secrets start starter status statusall stop stroke
+ unroute uci up update version whack --confdir --copyright
+ --directory --help --version --versioncode'
return
fi
case ${words[1]} in
down | route | status | statusall | unroute | up)
local confdir=$(ipsec --confdir)
- _ipsec_connections <"$confdir/ipsec.conf"
+ _comp_cmd_ipsec__connections <"$confdir/ipsec.conf"
;;
list*)
- COMPREPLY=($(compgen -W '--utc' -- "$cur"))
+ _comp_compgen -- -W '--utc'
;;
restart | start)
- COMPREPLY=($(compgen -W '--attach-gdb --auto-update --debug
- --debug-all --debug-more --nofork' -- "$cur"))
+ _comp_compgen -- -W '--attach-gdb --auto-update --debug --debug-all
+ --debug-more --nofork'
;;
pki)
- COMPREPLY=($(compgen -W '--gen --issue --keyid --print --pub
- --req --self --signcrl --verify' -- "$cur"))
+ _comp_compgen -- -W '--gen --issue --keyid --print --pub --req
+ --self --signcrl --verify'
;;
pool) ;;
irdumm)
- _filedir 'rb'
+ _comp_compgen_filedir 'rb'
;;
*) ;;
@@ -92,10 +91,10 @@ _ipsec_strongswan()
case "$(ipsec --version 2>/dev/null)" in
*strongSwan*)
- complete -F _ipsec_strongswan ipsec
+ complete -F _comp_cmd_ipsec__strongswan ipsec
;;
*)
- complete -F _ipsec_freeswan ipsec
+ complete -F _comp_cmd_ipsec__freeswan ipsec
;;
esac
diff --git a/completions/iptables b/completions/iptables
index ffb905b..d0c0ec1 100644
--- a/completions/iptables
+++ b/completions/iptables
@@ -1,51 +1,55 @@
# bash completion for iptables -*- shell-script -*-
-_iptables()
+_comp_cmd_iptables()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local table chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p'
+ local table="" chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p'
+ local targets='ACCEPT DROP LOG ULOG REJECT'
+ local IFS=$' \t\n' # for ${table:+-t "$table"}
[[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] &&
- table="-t ${BASH_REMATCH[2]}"
+ table=${BASH_REMATCH[2]}
case $prev in
-*[AIDRPFXLZ])
- COMPREPLY=($(compgen -W '`"$1" $table -nL 2>/dev/null | \
- command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur"))
+ _comp_compgen_split -- "$(
+ "$1" ${table:+-t "$table"} -nL 2>/dev/null |
+ command sed -ne 's/^Chain \([^ ]\{1,\}\).*$/\1/p'
+ )"
;;
-*t)
- COMPREPLY=($(compgen -W 'nat filter mangle' -- "$cur"))
+ _comp_compgen -- -W 'nat filter mangle'
;;
-j)
- if [[ $table == "-t filter" || -z $table ]]; then
- COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT
- `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \
- -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
- "$cur"))
- elif [[ $table == "-t nat" ]]; then
- COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT
- DNAT MASQUERADE `"$1" $table -nL 2>/dev/null | \
- command sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
- -- "$cur"))
- elif [[ $table == "-t mangle" ]]; then
- COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS
- `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \
- -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
- "$cur"))
+ if [[ $table == "filter" || ! $table ]]; then
+ _comp_compgen -- -W '$targets'
+ _comp_compgen -a split -- "$("$1" ${table:+-t "$table"} -nL \
+ 2>/dev/null | command sed -ne "$chain" \
+ -e 's/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//')"
+ elif [[ $table == "nat" ]]; then
+ _comp_compgen -- -W '$targets MIRROR SNAT DNAT MASQUERADE'
+ _comp_compgen -a split -- "$("$1" -t "$table" -nL 2>/dev/null |
+ command sed -ne "$chain" \
+ -e 's/OUTPUT|PREROUTING|POSTROUTING//')"
+ elif [[ $table == "mangle" ]]; then
+ _comp_compgen -- -W '$targets MARK TOS'
+ _comp_compgen -a split -- "$("$1" -t "$table" -nL 2>/dev/null |
+ command sed -ne "$chain" \
+ -e 's/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//')"
fi
;;
*)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$("$1" --help 2>&1 |
- command sed -e "s/^\[\!\]//" | _parse_help -)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" --help 2>&1 |
+ command sed -e "s/^\[\!\]//")"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
;;
esac
} &&
- complete -F _iptables iptables
+ complete -F _comp_cmd_iptables iptables
# ex: filetype=sh
diff --git a/completions/ipv6calc b/completions/ipv6calc
index c452c15..7cf7d82 100644
--- a/completions/ipv6calc
+++ b/completions/ipv6calc
@@ -1,23 +1,24 @@
# ipv6calc completion -*- shell-script -*-
-_ipv6calc()
+_comp_cmd_ipv6calc()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[dIOA]*)'
+ # shellcheck disable=SC2254
case "$prev" in
- --debug | -!(-*)d)
+ --debug | -${noargopts}d)
return
;;
- --in | --out | --action | -!(-*)[IOA])
+ --in | --out | --action | -${noargopts}[IOA])
# With ipv6calc < 0.73.0, -m does nothing here, so use sed instead.
- COMPREPLY=($(compgen -W "$($1 "$prev" -h 2>&1 |
- command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" "$prev" -h 2>&1 |
+ command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p')"
return
;;
--db-geoip | --db-ip2location-ipv4 | --db-ip2location-ipv6)
- _filedir
+ _comp_compgen_filedir
return
;;
--printstart | --printend)
@@ -25,14 +26,14 @@ _ipv6calc()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$("$1" -h 2>&1 |
- command sed -e "s/[][]//g" | _parse_help -)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" -h 2>&1 |
+ command sed -e "s/[][]//g")"
fi
} &&
- complete -F _ipv6calc ipv6calc
+ complete -F _comp_cmd_ipv6calc ipv6calc
# ex: filetype=sh