@@ -8,35 +8,36 @@ _comp_cmd_ebtables()
8
8
local table=" " chain=' s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \
9
9
targets=' ACCEPT DROP CONTINUE RETURN'
10
10
11
+ local IFS=$' \t\n ' # for ${table:+-t "$table"}
11
12
[[ ${words[*]} =~ [[:space:]]-(t| -table=? )[[:space:]]* ([^[:space:]]+) ]] &&
12
- table=" -t ${BASH_REMATCH[2]} "
13
+ table=${BASH_REMATCH[2]}
13
14
14
15
local noargopts=' !(-*|*[AIDPFXLZtj]*)'
15
16
# shellcheck disable=SC2254
16
17
case $prev in
17
18
-${noargopts} [AIDPFXLZ])
18
- COMPREPLY=($( compgen -W ' `"$1" $table -L 2>/dev/null | \
19
+ COMPREPLY=($( compgen -W ' `"$1" ${ table:+-t "$table"} -L 2>/dev/null | \
19
20
command sed -ne "$chain"`' -- " $cur " ) )
20
21
;;
21
22
-${noargopts} t)
22
23
COMPREPLY=($( compgen -W ' nat filter broute' -- " $cur " ) )
23
24
;;
24
25
-${noargopts} j)
25
- if [[ $table == " -t filter" || ! $table ]]; then
26
+ if [[ $table == " filter" || ! $table ]]; then
26
27
COMPREPLY=($( compgen -W ' $targets
27
- $("$1" $table -L 2>/dev/null | \
28
+ $("$1" ${ table:+-t "$table"} -L 2>/dev/null | \
28
29
command sed -n -e "s/INPUT\|OUTPUT\|FORWARD//" \
29
30
-e "$chain")' \
30
31
-- " $cur " ) )
31
- elif [[ $table == " -t nat" ]]; then
32
+ elif [[ $table == " nat" ]]; then
32
33
COMPREPLY=($( compgen -W ' $targets
33
- $("$1" $table -L 2>/dev/null | \
34
+ $("$1" -t " $table" -L 2>/dev/null | \
34
35
command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \
35
36
-e "$chain")' \
36
37
-- " $cur " ) )
37
- elif [[ $table == " -t broute" ]]; then
38
+ elif [[ $table == " broute" ]]; then
38
39
COMPREPLY=($( compgen -W ' ACCEPT DROP
39
- $("$1" $table -L 2>/dev/null | \
40
+ $("$1" -t " $table" -L 2>/dev/null | \
40
41
command sed -n -e "s/BROUTING//" -e "$chain")' \
41
42
-- " $cur " ) )
42
43
fi
0 commit comments