summaryrefslogtreecommitdiffstats
path: root/completions/iptables
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
commit6c09f2a45c5541e9c207d14fc7aa21a4a0066bde (patch)
tree0221189d367bf661f6f9493c4f17a03f0dd4b7d2 /completions/iptables
parentReleasing progress-linux version 1:2.11-8~progress7.99u1. (diff)
downloadbash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.tar.xz
bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.zip
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/iptables')
-rw-r--r--completions/iptables56
1 files changed, 30 insertions, 26 deletions
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