diff options
Diffstat (limited to 'completions/ebtables')
-rw-r--r-- | completions/ebtables | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/completions/ebtables b/completions/ebtables index 05af7e39..325962b5 100644 --- a/completions/ebtables +++ b/completions/ebtables @@ -8,45 +8,40 @@ _ebtables() local table chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \ targets='ACCEPT DROP CONTINUE RETURN' - if [[ ${words[@]} == *-t\ *filter* ]]; then - table="-t filter" - elif [[ ${words[@]} == *-t\ *nat* ]]; then - table="-t nat" - elif [[ ${words[@]} == *-t\ *mangle* ]]; then - table="-t mangle" - fi + [[ "${words[*]}" =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] \ + && table="-t ${BASH_REMATCH[2]}" case $prev in - -*[AIDPFXLZ]) - COMPREPLY=( $( compgen -W '`"$1" $table -L 2>/dev/null | \ - command sed -ne "$chain"`' -- "$cur" ) ) + -!(-*)[AIDPFXLZ]) + COMPREPLY=( $(compgen -W '`"$1" $table -L 2>/dev/null | \ + command sed -ne "$chain"`' -- "$cur") ) ;; - -*t) - COMPREPLY=( $( compgen -W 'nat filter broute' -- "$cur" ) ) + -!(-*)t) + COMPREPLY=( $(compgen -W 'nat filter broute' -- "$cur") ) ;; - -j) + -!(-*)j) if [[ "$table" == "-t filter" || -z "$table" ]]; then - COMPREPLY=( $( compgen -W '$targets + COMPREPLY=( $(compgen -W '$targets $("$1" $table -L 2>/dev/null | \ command sed -n -e "s/INPUT\|OUTPUT\|FORWARD//" \ -e "$chain")' \ - -- "$cur" ) ) + -- "$cur") ) elif [[ $table == "-t nat" ]]; then - COMPREPLY=( $( compgen -W '$targets + COMPREPLY=( $(compgen -W '$targets $("$1" $table -L 2>/dev/null | \ command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \ -e "$chain")' \ - -- "$cur" ) ) + -- "$cur") ) elif [[ $table == "-t broute" ]]; then - COMPREPLY=( $( compgen -W 'ACCEPT DROP + COMPREPLY=( $(compgen -W 'ACCEPT DROP $("$1" $table -L 2>/dev/null | \ command sed -n -e "s/BROUTING//" -e "$chain")' \ - -- "$cur" ) ) + -- "$cur") ) fi ;; *) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--802_3-sap --802_3-type --among-dst + COMPREPLY=( $(compgen -W '--802_3-sap --802_3-type --among-dst --among-dst-file --among-src --among-src-file --append --arp-gratuitous --arp-htype --arp-ip-dst --arp-ip-src --arp-mac-dst --arp-mac-src --arp-opcode --arp-ptype --arpreply-mac @@ -72,7 +67,7 @@ _ebtables() --stp-sender-prio --stp-type --table --to-destination --to-dst --to-source --to-src --ulog --ulog-cprange --ulog-nlgroup --ulog-prefix --ulog-qthreshold --version --vlan-encap --vlan-id - --vlan-prio --zero' -- "$cur" ) ) + --vlan-prio --zero' -- "$cur") ) fi ;; esac |