summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Monnet <quentin.monnet@netronome.com>2019-07-08 09:05:46 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2019-07-08 11:20:34 -0400
commit8fc9f8bedf1bdaea48382ae2e3dd558e2b939cee (patch)
treef6ce48b546e604f7b99a51739b851c18b314b47e
parentbef8e2639242e7f7214f1ab3b37ace1415a4f750 (diff)
tools: bpftool: add completion for bpftool prog "loadall"
Bash completion for proposing the "loadall" subcommand is missing. Let's add it to the completion script. Add a specific case to propose "load" and "loadall" for completing: $ bpftool prog load ^ cursor is here Otherwise, completion considers that $command is in load|loadall and starts making related completions (file or directory names, as the number of words on the command line is below 6), when the only suggested keywords should be "load" and "loadall" until one has been picked and a space entered after that to move to the next word. Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--tools/bpf/bpftool/bash-completion/bpftool9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index 965a8658cca3..c8f42e1fcbc9 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -342,6 +342,13 @@ _bpftool()
342 load|loadall) 342 load|loadall)
343 local obj 343 local obj
344 344
345 # Propose "load/loadall" to complete "bpftool prog load",
346 # or bash tries to complete "load" as a filename below.
347 if [[ ${#words[@]} -eq 3 ]]; then
348 COMPREPLY=( $( compgen -W "load loadall" -- "$cur" ) )
349 return 0
350 fi
351
345 if [[ ${#words[@]} -lt 6 ]]; then 352 if [[ ${#words[@]} -lt 6 ]]; then
346 _filedir 353 _filedir
347 return 0 354 return 0
@@ -435,7 +442,7 @@ _bpftool()
435 *) 442 *)
436 [[ $prev == $object ]] && \ 443 [[ $prev == $object ]] && \
437 COMPREPLY=( $( compgen -W 'dump help pin attach detach \ 444 COMPREPLY=( $( compgen -W 'dump help pin attach detach \
438 load show list tracelog run' -- "$cur" ) ) 445 load loadall show list tracelog run' -- "$cur" ) )
439 ;; 446 ;;
440 esac 447 esac
441 ;; 448 ;;