Fix nftables completion: when object name contains its type name, the completion may mass up
E.g.
```
table inet foo {
chain my_chain {
jump my_chain2
}
chain my_chain2 {
}
}
```
`nft delete chain inet foo <tab>`
get
```
handle -- address chain by handle
my_chain2 -- (handle 31)
my_chain -- (handle 30)
\t\tjump my_chain2 # handle 33
```
the last line in the completion output is not wanted.
This commit is contained in:
parent
978e79e12c
commit
0bd94fb993
|
|
@ -468,7 +468,7 @@ _nft_object(){
|
||||||
#$3:object type (chain/set/map/flowtable/ct helper/counter/quota/meter)
|
#$3:object type (chain/set/map/flowtable/ct helper/counter/quota/meter)
|
||||||
#$4:include 'handle'?
|
#$4:include 'handle'?
|
||||||
local objects=( ${(f)"$(_call_program -p objects nft -a list table $1 $2 2>/dev/null\
|
local objects=( ${(f)"$(_call_program -p objects nft -a list table $1 $2 2>/dev/null\
|
||||||
| grep ""\\s\*$3"" | sed 's/\s*'"$3"' // ;s/ { # \(.*\)/:(\1)/' )"} )
|
| grep ""\^\\s\*$3"" | sed 's/\s*'"$3"' // ;s/ { # \(.*\)/:(\1)/' )"} )
|
||||||
if $4 ;then
|
if $4 ;then
|
||||||
objects+=( "handle:address $3 by handle")
|
objects+=( "handle:address $3 by handle")
|
||||||
fi
|
fi
|
||||||
|
|
@ -481,7 +481,7 @@ _nft_object_handle(){
|
||||||
#$2:table
|
#$2:table
|
||||||
#$3:object type (chain/set/ct helper/counter/quota)
|
#$3:object type (chain/set/ct helper/counter/quota)
|
||||||
local handles=( ${(f)"$(_call_program -p handles nft -a list table $1 $2 2>/dev/null\
|
local handles=( ${(f)"$(_call_program -p handles nft -a list table $1 $2 2>/dev/null\
|
||||||
| grep ""\\s\*$3"" | sed 's/\s*'"$3"' // ;s/ { # handle// ;s/\(\S*\) \(\S*\)/\2:\1/' )"} )
|
| grep ""\^\\s\*$3"" | sed 's/\s*'"$3"' // ;s/ { # handle// ;s/\(\S*\) \(\S*\)/\2:\1/' )"} )
|
||||||
_describe -t handles "$3-handle" handles
|
_describe -t handles "$3-handle" handles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue