diff options
Diffstat (limited to 'completions/ebtables')
-rw-r--r-- | completions/ebtables | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/completions/ebtables b/completions/ebtables index de6bc54..24f3fe7 100644 --- a/completions/ebtables +++ b/completions/ebtables @@ -1,47 +1,49 @@ # bash completion for ebtables -*- shell-script -*- -_ebtables() +_comp_cmd_ebtables() { - 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/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \ + local table="" chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \ targets='ACCEPT DROP CONTINUE RETURN' + local IFS=$' \t\n' # for ${table:+-t "$table"} [[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] && - table="-t ${BASH_REMATCH[2]}" + table=${BASH_REMATCH[2]} + local noargopts='!(-*|*[AIDPFXLZtj]*)' + # shellcheck disable=SC2254 case $prev in - -!(-*)[AIDPFXLZ]) - COMPREPLY=($(compgen -W '`"$1" $table -L 2>/dev/null | \ - command sed -ne "$chain"`' -- "$cur")) + -${noargopts}[AIDPFXLZ]) + _comp_compgen_split -- "$( + "$1" ${table:+-t "$table"} -L 2>/dev/null | + command sed -ne "$chain" + )" ;; - -!(-*)t) - COMPREPLY=($(compgen -W 'nat filter broute' -- "$cur")) + -${noargopts}t) + _comp_compgen -- -W 'nat filter broute' ;; - -!(-*)j) - if [[ $table == "-t filter" || -z $table ]]; then - COMPREPLY=($(compgen -W '$targets - $("$1" $table -L 2>/dev/null | \ - command sed -n -e "s/INPUT\|OUTPUT\|FORWARD//" \ - -e "$chain")' \ - -- "$cur")) - elif [[ $table == "-t nat" ]]; then - COMPREPLY=($(compgen -W '$targets - $("$1" $table -L 2>/dev/null | \ - command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \ - -e "$chain")' \ - -- "$cur")) - elif [[ $table == "-t broute" ]]; then - COMPREPLY=($(compgen -W 'ACCEPT DROP - $("$1" $table -L 2>/dev/null | \ - command sed -n -e "s/BROUTING//" -e "$chain")' \ - -- "$cur")) + -${noargopts}j) + if [[ $table == "filter" || ! $table ]]; then + _comp_compgen -- -W '$targets' + _comp_compgen -a split -- "$("$1" ${table:+-t "$table"} -L \ + 2>/dev/null | command sed -n -e \ + "s/INPUT\|OUTPUT\|FORWARD//" -e "$chain")" + elif [[ $table == "nat" ]]; then + _comp_compgen -- -W '$targets' + _comp_compgen -a split -- "$("$1" -t "$table" -L 2>/dev/null | + command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \ + -e "$chain")" + elif [[ $table == "broute" ]]; then + _comp_compgen -- -W 'ACCEPT DROP' + _comp_compgen -a split -- "$("$1" -t "$table" -L 2>/dev/null | + command sed -n -e "s/BROUTING//" -e "$chain")" fi ;; *) if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '--802_3-sap --802_3-type --among-dst + _comp_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 @@ -67,12 +69,12 @@ _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' fi ;; esac } && - complete -F _ebtables ebtables + complete -F _comp_cmd_ebtables ebtables # ex: filetype=sh |