tools: bpftool: Fix minor bash completion mistakes

Minor fixes for bash completion: addition of program name completion for
two subcommands, and correction for program test-runs and map pinning.

The completion for the following commands is fixed or improved:

    # bpftool prog run [TAB]
    # bpftool prog pin [TAB]
    # bpftool map pin [TAB]
    # bpftool net attach xdp name [TAB]

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200312184608.12050-3-quentin@isovalent.com
This commit is contained in:
Quentin Monnet 2020-03-12 18:46:08 +00:00 committed by Daniel Borkmann
parent 75a1e792c3
commit 132c1af0a2

View File

@ -542,8 +542,8 @@ _bpftool()
esac
;;
run)
if [[ ${#words[@]} -lt 5 ]]; then
_filedir
if [[ ${#words[@]} -eq 4 ]]; then
COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) )
return 0
fi
case $prev in
@ -551,6 +551,10 @@ _bpftool()
_bpftool_get_prog_ids
return 0
;;
name)
_bpftool_get_prog_names
return 0
;;
data_in|data_out|ctx_in|ctx_out)
_filedir
return 0
@ -756,11 +760,17 @@ _bpftool()
esac
;;
pin)
if [[ $prev == "$command" ]]; then
COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) )
else
_filedir
fi
case $prev in
$command)
COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) )
;;
id)
_bpftool_get_map_ids
;;
name)
_bpftool_get_map_names
;;
esac
return 0
;;
event_pipe)
@ -987,6 +997,9 @@ _bpftool()
id)
_bpftool_get_prog_ids
;;
name)
_bpftool_get_prog_names
;;
pinned)
_filedir
;;