Skip to content

Commit

Permalink
tools: bpftool: Fix minor bash completion mistakes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Quentin Monnet authored and Daniel Borkmann committed Mar 12, 2020
1 parent 75a1e79 commit 132c1af
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions tools/bpf/bpftool/bash-completion/bpftool
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,19 @@ _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
id)
_bpftool_get_prog_ids
return 0
;;
name)
_bpftool_get_prog_names
return 0
;;
data_in|data_out|ctx_in|ctx_out)
_filedir
return 0
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -887,7 +897,7 @@ _bpftool()
case $command in
skeleton)
_filedir
;;
;;
*)
[[ $prev == $object ]] && \
COMPREPLY=( $( compgen -W 'skeleton help' -- "$cur" ) )
Expand Down Expand Up @@ -987,6 +997,9 @@ _bpftool()
id)
_bpftool_get_prog_ids
;;
name)
_bpftool_get_prog_names
;;
pinned)
_filedir
;;
Expand Down

0 comments on commit 132c1af

Please sign in to comment.