mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-28 07:04:00 +08:00
bpftool: Add link bash completions
Extend bpftool's bash-completion script to handle new link command and its sub-commands. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/bpf/20200429001614.1544-11-andriin@fb.com
This commit is contained in:
parent
7464d013cc
commit
5d085ad2e6
@ -98,6 +98,12 @@ _bpftool_get_btf_ids()
|
||||
command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ) )
|
||||
}
|
||||
|
||||
_bpftool_get_link_ids()
|
||||
{
|
||||
COMPREPLY+=( $( compgen -W "$( bpftool -jp link 2>&1 | \
|
||||
command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ) )
|
||||
}
|
||||
|
||||
_bpftool_get_obj_map_names()
|
||||
{
|
||||
local obj
|
||||
@ -1082,6 +1088,39 @@ _bpftool()
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
link)
|
||||
case $command in
|
||||
show|list|pin)
|
||||
case $prev in
|
||||
id)
|
||||
_bpftool_get_link_ids
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
local LINK_TYPE='id pinned'
|
||||
case $command in
|
||||
show|list)
|
||||
[[ $prev != "$command" ]] && return 0
|
||||
COMPREPLY=( $( compgen -W "$LINK_TYPE" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
pin)
|
||||
if [[ $prev == "$command" ]]; then
|
||||
COMPREPLY=( $( compgen -W "$LINK_TYPE" -- "$cur" ) )
|
||||
else
|
||||
_filedir
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
[[ $prev == $object ]] && \
|
||||
COMPREPLY=( $( compgen -W 'help pin show list' -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
} &&
|
||||
complete -F _bpftool bpftool
|
||||
|
Loading…
Reference in New Issue
Block a user