Commit 132c1af0 authored by Quentin Monnet's avatar Quentin Monnet Committed by Daniel Borkmann

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: default avatarQuentin Monnet <quentin@isovalent.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200312184608.12050-3-quentin@isovalent.com
parent 75a1e792
...@@ -542,8 +542,8 @@ _bpftool() ...@@ -542,8 +542,8 @@ _bpftool()
esac esac
;; ;;
run) run)
if [[ ${#words[@]} -lt 5 ]]; then if [[ ${#words[@]} -eq 4 ]]; then
_filedir COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) )
return 0 return 0
fi fi
case $prev in case $prev in
...@@ -551,6 +551,10 @@ _bpftool() ...@@ -551,6 +551,10 @@ _bpftool()
_bpftool_get_prog_ids _bpftool_get_prog_ids
return 0 return 0
;; ;;
name)
_bpftool_get_prog_names
return 0
;;
data_in|data_out|ctx_in|ctx_out) data_in|data_out|ctx_in|ctx_out)
_filedir _filedir
return 0 return 0
...@@ -756,11 +760,17 @@ _bpftool() ...@@ -756,11 +760,17 @@ _bpftool()
esac esac
;; ;;
pin) pin)
if [[ $prev == "$command" ]]; then case $prev in
COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) ) $command)
else COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) )
_filedir ;;
fi id)
_bpftool_get_map_ids
;;
name)
_bpftool_get_map_names
;;
esac
return 0 return 0
;; ;;
event_pipe) event_pipe)
...@@ -887,7 +897,7 @@ _bpftool() ...@@ -887,7 +897,7 @@ _bpftool()
case $command in case $command in
skeleton) skeleton)
_filedir _filedir
;; ;;
*) *)
[[ $prev == $object ]] && \ [[ $prev == $object ]] && \
COMPREPLY=( $( compgen -W 'skeleton help' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'skeleton help' -- "$cur" ) )
...@@ -987,6 +997,9 @@ _bpftool() ...@@ -987,6 +997,9 @@ _bpftool()
id) id)
_bpftool_get_prog_ids _bpftool_get_prog_ids
;; ;;
name)
_bpftool_get_prog_names
;;
pinned) pinned)
_filedir _filedir
;; ;;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment